code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package com.ch_linghu.fanfoudroid.util; import java.io.InputStream; import java.io.OutputStream; public class StreamUtils { public static void CopyStream(InputStream is, OutputStream os) { final int buffer_size=1024; try { byte[] bytes=new byte[buffer_size]; for(;;) { int count=is.read(bytes, 0, buffer_size); if(count==-1) break; os.write(bytes, 0, count); } } catch(Exception ex){} } }
061304011116lyj-a
src/com/ch_linghu/fanfoudroid/util/StreamUtils.java
Java
asf20
572
package com.ch_linghu.fanfoudroid.util; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Arrays; import java.util.HashMap; import android.util.Log; import com.ch_linghu.fanfoudroid.TwitterApplication; /** * Debug Timer * * Usage: * -------------------------------- * DebugTimer.start(); * DebugTimer.mark("my_mark1"); // optional * DebugTimer.stop(); * * System.out.println(DebugTimer.__toString()); // get report * -------------------------------- * * @author LDS */ public class DebugTimer { public static final int START = 0; public static final int END = 1; private static HashMap<String, Long> mTime = new HashMap<String, Long>(); private static long mStartTime = 0; private static long mLastTime = 0; /** * Start a timer */ public static void start() { reset(); mStartTime = touch(); } /** * Mark current time * * @param tag mark tag * @return */ public static long mark(String tag) { long time = System.currentTimeMillis() - mStartTime; mTime.put(tag, time); return time; } /** * Mark current time * * @param tag mark tag * @return */ public static long between(String tag, int startOrEnd) { if(TwitterApplication.DEBUG){ Log.v("DEBUG", tag + " " + startOrEnd); } switch (startOrEnd) { case START: return mark(tag); case END: long time = System.currentTimeMillis() - mStartTime - get(tag, mStartTime); mTime.put(tag, time); //touch(); return time; default: return -1; } } public static long betweenStart(String tag) { return between(tag, START); } public static long betweenEnd(String tag) { return between(tag, END); } /** * Stop timer * * @return result */ public static String stop() { mTime.put("_TOTLE", touch() - mStartTime); return __toString(); } public static String stop(String tag) { mark(tag); return stop(); } /** * Get a mark time * * @param tag mark tag * @return time(milliseconds) or NULL */ public static long get(String tag) { return get(tag, 0); } public static long get(String tag, long defaultValue) { if (mTime.containsKey(tag)) { return mTime.get(tag); } return defaultValue; } /** * Reset timer */ public static void reset() { mTime = new HashMap<String, Long>(); mStartTime = 0; mLastTime = 0; } /** * static toString() * * @return */ public static String __toString() { return "Debuger [time =" + mTime.toString() + "]"; } private static long touch() { return mLastTime = System.currentTimeMillis(); } public static DebugProfile[] getProfile() { DebugProfile[] profile = new DebugProfile[mTime.size()]; long totel = mTime.get("_TOTLE"); int i = 0; for (String key : mTime.keySet()) { long time = mTime.get(key); profile[i] = new DebugProfile(key, time, time/(totel*1.0) ); i++; } try { Arrays.sort(profile); } catch (NullPointerException e) { // in case item is null, do nothing } return profile; } public static String getProfileAsString() { StringBuilder sb = new StringBuilder(); for (DebugProfile p : getProfile()) { sb.append("TAG: "); sb.append(p.tag); sb.append("\t INC: "); sb.append(p.inc); sb.append("\t INCP: "); sb.append(p.incPercent); sb.append("\n"); } return sb.toString(); } @Override public String toString() { return __toString(); } } class DebugProfile implements Comparable<DebugProfile> { private static NumberFormat percent = NumberFormat.getPercentInstance(); public String tag; public long inc; public String incPercent; public DebugProfile(String tag, long inc, double incPercent) { this.tag = tag; this.inc = inc; percent = new DecimalFormat("0.00#%"); this.incPercent = percent.format(incPercent); } @Override public int compareTo(DebugProfile o) { // TODO Auto-generated method stub return (int) (o.inc - this.inc); } }
061304011116lyj-a
src/com/ch_linghu/fanfoudroid/util/DebugTimer.java
Java
asf20
4,762
package com.ch_linghu.fanfoudroid.util; import java.io.File; import java.io.IOException; import android.os.Environment; /** * 对SD卡文件的管理 * @author ch.linghu * */ public class FileHelper { private static final String TAG = "FileHelper"; private static final String BASE_PATH="fanfoudroid"; public static File getBasePath() throws IOException{ File basePath = new File(Environment.getExternalStorageDirectory(), BASE_PATH); if (!basePath.exists()){ if (!basePath.mkdirs()){ throw new IOException(String.format("%s cannot be created!", basePath.toString())); } } if (!basePath.isDirectory()){ throw new IOException(String.format("%s is not a directory!", basePath.toString())); } return basePath; } }
061304011116lyj-a
src/com/ch_linghu/fanfoudroid/util/FileHelper.java
Java
asf20
813
package com.ch_linghu.fanfoudroid.util; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import android.util.Log; import com.ch_linghu.fanfoudroid.R; import com.ch_linghu.fanfoudroid.TwitterApplication; import com.ch_linghu.fanfoudroid.db.TwitterDatabase; public class DateTimeHelper { private static final String TAG = "DateTimeHelper"; // Wed Dec 15 02:53:36 +0000 2010 public static final DateFormat TWITTER_DATE_FORMATTER = new SimpleDateFormat( "E MMM d HH:mm:ss Z yyyy", Locale.US); public static final DateFormat TWITTER_SEARCH_API_DATE_FORMATTER = new SimpleDateFormat( "E, d MMM yyyy HH:mm:ss Z", Locale.US); // TODO: Z -> z ? public static final Date parseDateTime(String dateString) { try { Log.v(TAG, String.format("in parseDateTime, dateString=%s", dateString)); return TWITTER_DATE_FORMATTER.parse(dateString); } catch (ParseException e) { Log.w(TAG, "Could not parse Twitter date string: " + dateString); return null; } } // Handle "yyyy-MM-dd'T'HH:mm:ss.SSS" from sqlite public static final Date parseDateTimeFromSqlite(String dateString) { try { Log.v(TAG, String.format("in parseDateTime, dateString=%s", dateString)); return TwitterDatabase.DB_DATE_FORMATTER.parse(dateString); } catch (ParseException e) { Log.w(TAG, "Could not parse Twitter date string: " + dateString); return null; } } public static final Date parseSearchApiDateTime(String dateString) { try { return TWITTER_SEARCH_API_DATE_FORMATTER.parse(dateString); } catch (ParseException e) { Log.w(TAG, "Could not parse Twitter search date string: " + dateString); return null; } } public static final DateFormat AGO_FULL_DATE_FORMATTER = new SimpleDateFormat( "yyyy-MM-dd HH:mm"); public static String getRelativeDate(Date date) { Date now = new Date(); String prefix = TwitterApplication.mContext .getString(R.string.tweet_created_at_beautify_prefix); String sec = TwitterApplication.mContext .getString(R.string.tweet_created_at_beautify_sec); String min = TwitterApplication.mContext .getString(R.string.tweet_created_at_beautify_min); String hour = TwitterApplication.mContext .getString(R.string.tweet_created_at_beautify_hour); String day = TwitterApplication.mContext .getString(R.string.tweet_created_at_beautify_day); String suffix = TwitterApplication.mContext .getString(R.string.tweet_created_at_beautify_suffix); // Seconds. long diff = (now.getTime() - date.getTime()) / 1000; if (diff < 0) { diff = 0; } if (diff < 60) { return diff + sec + suffix; } // Minutes. diff /= 60; if (diff < 60) { return prefix + diff + min + suffix; } // Hours. diff /= 60; if (diff < 24) { return prefix + diff + hour + suffix; } return AGO_FULL_DATE_FORMATTER.format(date); } public static long getNowTime() { return Calendar.getInstance().getTime().getTime(); } }
061304011116lyj-a
src/com/ch_linghu/fanfoudroid/util/DateTimeHelper.java
Java
asf20
3,539
/*** Copyright (c) 2008-2009 CommonsWare, LLC Portions (c) 2009 Google, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.commonsware.cwac.sacklist; import java.util.ArrayList; import java.util.List; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; /** * Adapter that simply returns row views from a list. * * If you supply a size, you must implement newView(), to * create a required view. The adapter will then cache these * views. * * If you supply a list of views in the constructor, that * list will be used directly. If any elements in the list * are null, then newView() will be called just for those * slots. * * Subclasses may also wish to override areAllItemsEnabled() * (default: false) and isEnabled() (default: false), if some * of their rows should be selectable. * * It is assumed each view is unique, and therefore will not * get recycled. * * Note that this adapter is not designed for long lists. It * is more for screens that should behave like a list. This * is particularly useful if you combine this with other * adapters (e.g., SectionedAdapter) that might have an * arbitrary number of rows, so it all appears seamless. */ public class SackOfViewsAdapter extends BaseAdapter { private List<View> views=null; /** * Constructor creating an empty list of views, but with * a specified count. Subclasses must override newView(). */ public SackOfViewsAdapter(int count) { super(); views=new ArrayList<View>(count); for (int i=0;i<count;i++) { views.add(null); } } /** * Constructor wrapping a supplied list of views. * Subclasses must override newView() if any of the elements * in the list are null. */ public SackOfViewsAdapter(List<View> views) { super(); this.views=views; } /** * Get the data item associated with the specified * position in the data set. * @param position Position of the item whose data we want */ @Override public Object getItem(int position) { return(views.get(position)); } /** * How many items are in the data set represented by this * Adapter. */ @Override public int getCount() { return(views.size()); } /** * Returns the number of types of Views that will be * created by getView(). */ @Override public int getViewTypeCount() { return(getCount()); } /** * Get the type of View that will be created by getView() * for the specified item. * @param position Position of the item whose data we want */ @Override public int getItemViewType(int position) { return(position); } /** * Are all items in this ListAdapter enabled? If yes it * means all items are selectable and clickable. */ @Override public boolean areAllItemsEnabled() { return(false); } /** * Returns true if the item at the specified position is * not a separator. * @param position Position of the item whose data we want */ @Override public boolean isEnabled(int position) { return(false); } /** * Get a View that displays the data at the specified * position in the data set. * @param position Position of the item whose data we want * @param convertView View to recycle, if not null * @param parent ViewGroup containing the returned View */ @Override public View getView(int position, View convertView, ViewGroup parent) { View result=views.get(position); if (result==null) { result=newView(position, parent); views.set(position, result); } return(result); } /** * Get the row id associated with the specified position * in the list. * @param position Position of the item whose data we want */ @Override public long getItemId(int position) { return(position); } /** * Create a new View to go into the list at the specified * position. * @param position Position of the item whose data we want * @param parent ViewGroup containing the returned View */ protected View newView(int position, ViewGroup parent) { throw new RuntimeException("You must override newView()!"); } }
061304011116lyj-a
src/com/commonsware/cwac/sacklist/SackOfViewsAdapter.java
Java
asf20
4,593
/*** Copyright (c) 2008-2009 CommonsWare, LLC Portions (c) 2009 Google, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.commonsware.cwac.merge; import java.util.ArrayList; import java.util.List; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ListAdapter; import android.widget.SectionIndexer; import com.commonsware.cwac.sacklist.SackOfViewsAdapter; /** * Adapter that merges multiple child adapters and views * into a single contiguous whole. * * Adapters used as pieces within MergeAdapter must * have view type IDs monotonically increasing from 0. Ideally, * adapters also have distinct ranges for their row ids, as * returned by getItemId(). * */ public class MergeAdapter extends BaseAdapter implements SectionIndexer { private ArrayList<ListAdapter> pieces=new ArrayList<ListAdapter>(); /** * Stock constructor, simply chaining to the superclass. */ public MergeAdapter() { super(); } /** * Adds a new adapter to the roster of things to appear * in the aggregate list. * @param adapter Source for row views for this section */ public void addAdapter(ListAdapter adapter) { pieces.add(adapter); adapter.registerDataSetObserver(new CascadeDataSetObserver()); } /** * Adds a new View to the roster of things to appear * in the aggregate list. * @param view Single view to add */ public void addView(View view) { addView(view, false); } /** * Adds a new View to the roster of things to appear * in the aggregate list. * @param view Single view to add * @param enabled false if views are disabled, true if enabled */ public void addView(View view, boolean enabled) { ArrayList<View> list=new ArrayList<View>(1); list.add(view); addViews(list, enabled); } /** * Adds a list of views to the roster of things to appear * in the aggregate list. * @param views List of views to add */ public void addViews(List<View> views) { addViews(views, false); } /** * Adds a list of views to the roster of things to appear * in the aggregate list. * @param views List of views to add * @param enabled false if views are disabled, true if enabled */ public void addViews(List<View> views, boolean enabled) { if (enabled) { addAdapter(new EnabledSackAdapter(views)); } else { addAdapter(new SackOfViewsAdapter(views)); } } /** * Get the data item associated with the specified * position in the data set. * @param position Position of the item whose data we want */ @Override public Object getItem(int position) { for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { return(piece.getItem(position)); } position-=size; } return(null); } /** * Get the adapter associated with the specified * position in the data set. * @param position Position of the item whose adapter we want */ public ListAdapter getAdapter(int position) { for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { return(piece); } position-=size; } return(null); } /** * How many items are in the data set represented by this * Adapter. */ @Override public int getCount() { int total=0; for (ListAdapter piece : pieces) { total+=piece.getCount(); } return(total); } /** * Returns the number of types of Views that will be * created by getView(). */ @Override public int getViewTypeCount() { int total=0; for (ListAdapter piece : pieces) { total+=piece.getViewTypeCount(); } return(Math.max(total, 1)); // needed for setListAdapter() before content add' } /** * Get the type of View that will be created by getView() * for the specified item. * @param position Position of the item whose data we want */ @Override public int getItemViewType(int position) { int typeOffset=0; int result=-1; for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { result=typeOffset+piece.getItemViewType(position); break; } position-=size; typeOffset+=piece.getViewTypeCount(); } return(result); } /** * Are all items in this ListAdapter enabled? If yes it * means all items are selectable and clickable. */ @Override public boolean areAllItemsEnabled() { return(false); } /** * Returns true if the item at the specified position is * not a separator. * @param position Position of the item whose data we want */ @Override public boolean isEnabled(int position) { for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { return(piece.isEnabled(position)); } position-=size; } return(false); } /** * Get a View that displays the data at the specified * position in the data set. * @param position Position of the item whose data we want * @param convertView View to recycle, if not null * @param parent ViewGroup containing the returned View */ @Override public View getView(int position, View convertView, ViewGroup parent) { for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { return(piece.getView(position, convertView, parent)); } position-=size; } return(null); } /** * Get the row id associated with the specified position * in the list. * @param position Position of the item whose data we want */ @Override public long getItemId(int position) { for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { return(piece.getItemId(position)); } position-=size; } return(-1); } @Override public int getPositionForSection(int section) { int position=0; for (ListAdapter piece : pieces) { if (piece instanceof SectionIndexer) { Object[] sections=((SectionIndexer)piece).getSections(); int numSections=0; if (sections!=null) { numSections=sections.length; } if (section<numSections) { return(position+((SectionIndexer)piece).getPositionForSection(section)); } else if (sections!=null) { section-=numSections; } } position+=piece.getCount(); } return(0); } @Override public int getSectionForPosition(int position) { int section=0; for (ListAdapter piece : pieces) { int size=piece.getCount(); if (position<size) { if (piece instanceof SectionIndexer) { return(section+((SectionIndexer)piece).getSectionForPosition(position)); } return(0); } else { if (piece instanceof SectionIndexer) { Object[] sections=((SectionIndexer)piece).getSections(); if (sections!=null) { section+=sections.length; } } } position-=size; } return(0); } @Override public Object[] getSections() { ArrayList<Object> sections=new ArrayList<Object>(); for (ListAdapter piece : pieces) { if (piece instanceof SectionIndexer) { Object[] curSections=((SectionIndexer)piece).getSections(); if (curSections!=null) { for (Object section : curSections) { sections.add(section); } } } } if (sections.size()==0) { return(null); } return(sections.toArray(new Object[0])); } private static class EnabledSackAdapter extends SackOfViewsAdapter { public EnabledSackAdapter(List<View> views) { super(views); } @Override public boolean areAllItemsEnabled() { return(true); } @Override public boolean isEnabled(int position) { return(true); } } private class CascadeDataSetObserver extends DataSetObserver { @Override public void onChanged() { notifyDataSetChanged(); } @Override public void onInvalidated() { notifyDataSetInvalidated(); } } }
061304011116lyj-a
src/com/commonsware/cwac/merge/MergeAdapter.java
Java
asf20
8,420
package com.hlidskialf.android.hardware; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; public class ShakeListener implements SensorEventListener { private static final int FORCE_THRESHOLD = 350; private static final int TIME_THRESHOLD = 100; private static final int SHAKE_TIMEOUT = 500; private static final int SHAKE_DURATION = 1000; private static final int SHAKE_COUNT = 3; private SensorManager mSensorMgr; private Sensor mSensor; private float mLastX = -1.0f, mLastY = -1.0f, mLastZ = -1.0f; private long mLastTime; private OnShakeListener mShakeListener; private Context mContext; private int mShakeCount = 0; private long mLastShake; private long mLastForce; public interface OnShakeListener { public void onShake(); } public ShakeListener(Context context) { mContext = context; resume(); } public void setOnShakeListener(OnShakeListener listener) { mShakeListener = listener; } public void resume() { mSensorMgr = (SensorManager) mContext .getSystemService(Context.SENSOR_SERVICE); mSensor = mSensorMgr .getDefaultSensor(SensorManager.SENSOR_ACCELEROMETER); if (mSensorMgr == null) { throw new UnsupportedOperationException("Sensors not supported"); } boolean supported = mSensorMgr.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_GAME); if (!supported) { mSensorMgr.unregisterListener(this, mSensor); throw new UnsupportedOperationException( "Accelerometer not supported"); } } public void pause() { if (mSensorMgr != null) { mSensorMgr.unregisterListener(this, mSensor); mSensorMgr = null; } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } @Override public void onSensorChanged(SensorEvent event) { Sensor sensor = event.sensor; float[] values = event.values; if (sensor.getType() != SensorManager.SENSOR_ACCELEROMETER) return; long now = System.currentTimeMillis(); if ((now - mLastForce) > SHAKE_TIMEOUT) { mShakeCount = 0; } if ((now - mLastTime) > TIME_THRESHOLD) { long diff = now - mLastTime; float speed = Math.abs(values[SensorManager.DATA_X] + values[SensorManager.DATA_Y] + values[SensorManager.DATA_Z] - mLastX - mLastY - mLastZ) / diff * 10000; if (speed > FORCE_THRESHOLD) { if ((++mShakeCount >= SHAKE_COUNT) && (now - mLastShake > SHAKE_DURATION)) { mLastShake = now; mShakeCount = 0; if (mShakeListener != null) { mShakeListener.onShake(); } } mLastForce = now; } mLastTime = now; mLastX = values[SensorManager.DATA_X]; mLastY = values[SensorManager.DATA_Y]; mLastZ = values[SensorManager.DATA_Z]; } } }
061304011116lyj-a
src/com/hlidskialf/android/hardware/ShakeListener.java
Java
asf20
2,826
/* Javadoc 样式表 */ /* 在此处定义颜色、字体和其他样式属性以覆盖默认值 */ /* 页面背景颜色 */ body { background-color: #FFFFFF; color:#000000 } /* 标题 */ h1 { font-size: 145% } /* 表格颜色 */ .TableHeadingColor { background: #CCCCFF; color:#000000 } /* 深紫色 */ .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* 淡紫色 */ .TableRowColor { background: #FFFFFF; color:#000000 } /* 白色 */ /* 左侧的框架列表中使用的字体 */ .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } /* 导航栏字体和颜色 */ .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* 淡紫色 */ .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* 深蓝色 */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
061304011116lyj-a
doc/stylesheet.css
CSS
asf20
1,370
#!/bin/bash # 打开apache.http调试信息 adb shell setprop log.tag.org.apache.http VERBOSE adb shell setprop log.tag.org.apache.http.wire VERBOSE adb shell setprop log.tag.org.apache.http.headers VERBOSE echo "Enable Debug"
061304011116lyj-a
tools/openHttpDebug.sh
Shell
asf20
229
<?php /* * 爱客网单入口 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ //定义网站根目录,APP目录,DATA目录,核心目录 define ( 'IN_IK', true ); define ( 'IKROOT', dirname ( __FILE__ ) ); define ( 'IKAPP', IKROOT . '/app' ); define ( 'IKDATA', IKROOT . '/data' ); define ( 'IKCORE', IKROOT . '/core' ); define ( 'IKINSTALL', IKROOT . '/install' ); define ( 'IKPLUGIN', IKROOT . '/plugins' ); //装载12IK核心 include 'core/core.php'; //除去加载内核运行时间统计开始 $time_start = getmicrotime (); if (is_file ( 'data/config.inc.php' )) { //装载APP应用 include 'app/index.php'; } else { //装载安装程序 include 'install/index.php'; } unset ( $GLOBALS );
12ik
trunk/index.php
PHP
oos
803
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12ik爱客网 安装程序 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ //安装文件的IMG,CSS文件 $skins = 'data/install/skins/'; //进入正题 $title = '12IK-爱客网安装程序'; require_once 'action/' . $install . '.php';
12ik
trunk/install/index.php
PHP
oos
371
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12ik爱客网 安装程序 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ //判断目录可写 $f_cache = iswriteable ( 'cache' ); $f_data = iswriteable ( 'data' ); $f_plugins = iswriteable ( 'plugins' ); $f_uploadfile = iswriteable ( 'uploadfile' ); include 'install/html/index.html';
12ik
trunk/install/action/index.php
PHP
oos
421
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12ik爱客网 安装程序 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ $site_url = getHttpUrl (); include 'install/html/next.html';
12ik
trunk/install/action/next.php
PHP
oos
266
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12ik爱客网 安装程序 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ $host = trim ( $_POST ['host'] ); $port = trim ( $_POST ['port'] ); $user = trim ( $_POST ['user'] ); $pwd = trim ( $_POST ['pwd'] ); $name = trim ( $_POST ['name'] ); $pre = trim ( $_POST ['pre'] ); $select_sql = trim ( $_POST ['sql'] ); $arrdb = array ('host' => $host, 'port' => $port, 'user' => $user, 'pwd' => $pwd, 'name' => $name, 'pre' => $pre ); //网站信息 $site_title = trim ( $_POST ['site_title'] ); $site_subtitle = trim ( $_POST ['site_subtitle'] ); $site_url = trim ( $_POST ['site_url'] ); //用户信息 $email = trim ( $_POST ['email'] ); $password = trim ( $_POST ['password'] ); $username = trim ( $_POST ['username'] ); if (! preg_match ( "/^[\w_]+_$/", $pre )) qiMsg ( "数据表前缀不符合(例如:ik_)" ); if ($site_title == '' || $site_subtitle == '' || $site_url == '') qiMsg ( "网站信息不能为空!" ); if ($email == '' || $password == '' || $username == '') qiMsg ( "用户信息不能为空!" ); if (valid_email ( $email ) == false) qiMsg ( "Email输入有误!" ); include 'core/sql/mysql.php'; $db = new MySql ( $arrdb ); if ($db) { $sql = file_get_contents ( 'install/data.sql' ); $sql = str_replace ( 'ik_', $pre, $sql ); $array_sql = preg_split ( "/;[\r\n]/", $sql ); foreach ( $array_sql as $sql ) { $sql = trim ( $sql ); if ($sql) { if (strstr ( $sql, 'CREATE TABLE' )) { preg_match ( '/CREATE TABLE ([^ ]*)/', $sql, $matches ); $ret = $db->query ( $sql ); } else { $ret = $db->query ( $sql ); } } } //存入管理员数据 $salt = md5 ( rand () ); $userid = $db->query ( "insert into " . $pre . "user (`pwd` , `salt`,`email`) values ('" . md5 ( $salt . $password ) . "', '$salt' ,'$email');" ); $db->query ( "insert into " . $pre . "user_info (`userid`,`username`,`email`,`isadmin`,`addtime`,`uptime`) values ('$userid','$username','$email','1','" . time () . "','" . time () . "')" ); //更改网站信息 $db->query ( "update " . $pre . "system_options set `optionvalue`='$site_title' where `optionname`='site_title'" ); $db->query ( "update " . $pre . "system_options set `optionvalue`='$site_subtitle' where `optionname`='site_subtitle'" ); $db->query ( "update " . $pre . "system_options set `optionvalue`='$site_url' where `optionname`='site_url'" ); $arrOptions = $db->fetch_all_assoc ( "select * from " . $pre . "system_options" ); foreach ( $arrOptions as $item ) { $arrOption [$item ['optionname']] = $item ['optionvalue']; } fileWrite ( 'system_options.php', 'data', $arrOption ); //生成配置文件 $fp = fopen ( IKDATA . '/config.inc.php', 'w' ); if (! is_writable ( IKDATA . '/config.inc.php' )) qiMsg ( "配置文件(data/config.inc.php)不可写。如果您使用的是Unix/Linux主机,请修改该文件的权限为777。如果您使用的是Windows主机,请联系管理员,将此文件设为everyone可写" ); $config = "<?php\n" . " /*\n" . " *数据库配置\n" . " */\n" . " \n" . " \$IK_DB['sql']='" . $select_sql . "';\n" . " \$IK_DB['host']='" . $host . "';\n" . " \$IK_DB['port']='" . $port . "';\n" . " \$IK_DB['user']='" . $user . "';\n" . " \$IK_DB['pwd']='" . $pwd . "';\n" . " \$IK_DB['name']='" . $name . "';\n" . " \$IK_DB['pre']='" . $pre . "';\n" . " define('dbprefix','" . $pre . "');\n"; $fw = fwrite ( $fp, $config ); $strUser ['email'] = $email; $strUser ['password'] = $password; include 'install/html/result.html'; } else { include 'install/html/error.html'; }
12ik
trunk/install/action/result.php
PHP
oos
3,755
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $title; ?></title> <link type="text/css" rel="stylesheet" href="install/skins/style.css" /> </head> <body> <!--header--> <div class="header"> <div class="head"> <div class="logo"><a href="index.php"><img src="install/skins/logo.gif" alt="12IK安装程序" /></a></div> <div class="menu">12IK安装程序 <?php echo $IK_SOFT[info][version]; ?> </div> </div> </div>
12ik
trunk/install/html/header.html
HTML
oos
641
<?php include 'header.html'; ?> <style> .main{ background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #DFDFDF; border-radius: 11px 11px 11px 11px; color: #333333; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; margin: 2em auto; padding: 1em 2em; width: 700px; } p, li, dd, dt { font-size: 12px; line-height: 18px; padding-bottom: 2px; } .step { margin: 20px 0 15px; } .step, th { padding: 0; text-align: left; } .submit input, .button, .button-secondary { -moz-box-sizing: content-box; border: 1px solid #BBBBBB; border-radius: 15px 15px 15px 15px; color: #464646; cursor: pointer; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 14px !important; line-height: 16px; padding: 6px 12px; text-decoration: none; } .button:hover, .button-secondary:hover, .submit input:hover { border-color: #666666; color: #000000; } .button, .submit input, .button-secondary { background:#F2F2F2; } .button:active, .submit input:active, .button-secondary:active { background: #EEEEEE; } .form-table { border-collapse: collapse; margin-top: 1em; width: 100%; } .form-table td { border-bottom: 8px solid #FFFFFF; font-size: 12px; margin-bottom: 9px; padding: 10px; } .form-table th { border-bottom: 8px solid #FFFFFF; font-size: 13px; padding: 16px 10px 10px; text-align: left; vertical-align: top; width: 130px; } .form-table tr { background: none repeat scroll 0 0 #F3F3F3; } .form-table code { font-size: 18px; line-height: 18px; } .form-table p { font-size: 11px; margin: 4px 0 0; } .form-table input { font-size: 15px; line-height: 20px; padding: 2px; } .form-table th p { font-weight: normal; } #error-page { margin-top: 50px; } #error-page p { font-size: 12px; line-height: 18px; margin: 25px 0 20px; } #error-page code, .code { font-family: Consolas,Monaco,Courier,monospace; } #pass-strength-result { background-color: #EEEEEE; border-color: #DDDDDD !important; border-style: solid; border-width: 1px; display: none; margin: 5px 5px 5px 1px; padding: 5px; text-align: center; width: 200px; } #pass-strength-result.bad { background-color: #FFB78C; border-color: #FF853C !important; } #pass-strength-result.good { background-color: #FFEC8B; border-color: #FFCC00 !important; } #pass-strength-result.short { background-color: #FFA0A0; border-color: #F04040 !important; } #pass-strength-result.strong { background-color: #C3FF88; border-color: #8DFF1C !important; } .message { background-color: #FFFFE0; border: 1px solid #E6DB55; margin: 5px 0 15px; padding: 0.3em 0.6em; } </style> <!--main--> <div class="midder"> <div class="main"> <form action="index.php?install=result" method="post"> <p>请在下方输入数据库相关信息。若您不清楚,请咨询主机提供商。</p> <table class="form-table"> <tbody><tr> <th scope="row"><label for="dbname">数据库名</label></th> <td><input type="text" value="12ik" size="25" id="dbname" name="name"></td> <td>您希望 12IK 使用哪个数据库运行?</td> </tr> <tr> <th scope="row"><label for="uname">用户名</label></th> <td><input type="text" value="root" size="25" id="uname" name="user"></td> <td>您的 MySQL 用户名</td> </tr> <tr> <th scope="row"><label for="pwd">密码</label></th> <td><input type="text" value="" size="25" id="pwd" name="pwd"></td> <td>... 以及 MySQL 密码。</td> </tr> <tr> <th scope="row"><label for="dbhost">数据库主机</label></th> <td><input type="text" value="localhost" size="25" id="dbhost" name="host"></td> <td>通常情况下,应填写 <code>localhost</code>,若测试连接失败,请联系主机提供商咨询。</td> </tr> <tr> <th scope="row"><label for="dbport">端口</label></th> <td><input type="text" value="3306" size="25" id="dbport" name="port"></td> <td>默认3306</td> </tr> <tr> <th scope="row"><label for="prefix">表名前缀</label></th> <td><input type="text" size="25" value="ik_" id="prefix" name="pre"></td> <td>若您希望在一个数据库中存放多个 12IK 的数据,请修改本项以做区分。</td> </tr> </tbody></table> <p>请在下面输入网站信息</p> <table class="form-table"> <tbody> <tr> <th scope="row"><label for="site_title">网站标题:</label></th> <td><input type="text" value="爱客网" size="25" name="site_title"></td> <td>也是你的网站名称</td> </tr> <tr> <th scope="row"><label for="site_subtitle">网站副标题:</label></th> <td><input type="text" value="又一个爱客社区" size="25" name="site_subtitle"></td> <td>用于首页副标题,紧跟网站标题之后</td> </tr> <tr> <th scope="row"><label for="site_url">网站URL:</label></th> <td><input type="text" value="<?php echo $site_url; ?>" size="25" name="site_url"></td> <td>正确填写,http://开头,/结尾</td> </tr> </tbody> </table> <p>请在下面输入管理员信息</p> <table class="form-table"> <tbody> <tr> <th scope="row"><label for="email">登录Email:</label></th> <td><input type="text" value="admin@admin.com" size="25" name="email"></td> <td>你用来登录和最高管理的账户</td> </tr> <tr> <th scope="row"><label for="password">登录密码:</label></th> <td><input type="text" value="000000" size="25" name="password"></td> <td>您的登录密码</td> </tr> <tr> <th scope="row"><label for="username">用户名:</label></th> <td><input type="text" value="admin" size="25" name="username"></td> <td>你的用户名</td> </tr> </tbody> </table> <p>选择数据库链接方式</p> <table class="form-table"> <tbody> <tr> <th scope="row"><label for="sql">选择连接方式:</label></th> <td><select name="sql"> <option value="mysql">MySQL</option> </select></td> <td><!-- 选择pdo_mysql需要php支持pdo_mysql扩展 --></td> </tr> </tbody> </table> <p class="step"><button class="button" onclick="javascript:history.go(-1);return false;" href="#" >上一步</button>&nbsp;&nbsp;&nbsp;<input type="submit" class="button" value="确认安装" name="submit"></p> </form> </div> </div> <?php include 'footer.html'; ?>
12ik
trunk/install/html/next.html
HTML
oos
6,768
<?php include 'header.html'; ?> <style> .main{ background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #DFDFDF; border-radius: 11px 11px 11px 11px; color: #333333; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; margin: 2em auto; padding: 1em 2em; width: 700px; } p, li, dd, dt { font-size: 12px; line-height: 18px; padding-bottom: 2px; } .step { margin: 20px 0 15px; } .step, th { padding: 0; text-align: left; } .submit input, .button, .button-secondary { -moz-box-sizing: content-box; border: 1px solid #BBBBBB; border-radius: 15px 15px 15px 15px; color: #464646; cursor: pointer; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 14px !important; line-height: 16px; padding: 6px 12px; text-decoration: none; } .button:hover, .button-secondary:hover, .submit input:hover { border-color: #666666; color: #000000; } .button, .submit input, .button-secondary { background:#F2F2F2; } .button:active, .submit input:active, .button-secondary:active { background: #EEEEEE; } </style> <!--main--> <div class="midder"> <div class="main"> <h2>欢迎使用 12IK(爱客网)开源程序!在您开始使用前,12IK 需要一些数据库的信息。下列信息将会被问到,请作好准备。</h2> <ol> <li>数据库名</li> <li>数据库用户用户名</li> <li>数据库用户密码</li> <li>数据库主机</li> <li>表名前缀(若您希望在一个数据表中安装多个 12IK,请手动填写数据库信息)</li> </ol> <h2>感谢您使用12IK系统</h2> <ol> <li>您可以在完全遵守本最终用户授权协议的基础上,将本软件应用于商业用途,而不必支付费用。如果采用12IK系统二次开发再发布,必须得到12IK开发团队的许可,否则我们将追究法律责任。 </li><li>您可以在协议规定的约束和限制范围内修改 12IK 源代码或界面风格以适应您的网站要求。 </li><li>您拥有使用本软件构建的网站中全部会员资料及相关信息等所有权,并独立承担与其内容的相关法律义务。 </li><li>获得商业授权之后,您可以依据所购买的授权类型中确定的技术支持期限、技术支持方式和技术支持内容,自授权时刻起,在技术支持期限内拥有通过指定的方式获得指定范围内的技术支持服务。商业授权用户享有反映和提出意见的权力,相关意见将被作为首要考虑,但没有一定被采纳的承诺或保证。 </li> <li>用户出于自愿而使用本软件,您必须了解使用本软件的风险,在尚未购买产品技术服务之前,我们不承诺提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。 </li><li>12IK开发团队不对使用本软件构建的网站中的信息承担责任。 </li> </ol> <!-- <p>出于各种原因,自动创建文件可能失败,但本向导只是助您在配置文件中写如数据库信息。此时,您只需用文本编辑器打开 config.sample.php,填入您的信息,另存为 config.inc.php 即可。</p> --> <p>大多数的互联网主机服务提供商都向您提供了数据库的信息。若您不知道这些信息,您需要先询问好,再进行安装。若您已准备好 …</p> <?php if($f_cache==0 || $f_data==0 || $f_plugins==0 || $f_uploadfile==0){ ?> <p>检测到以下目录不可写</p> <p> <?php if($f_cache==0){ ?>cache<?php } ?><br /> <?php if($f_data==0){ ?>data<?php } ?><br /> <?php if($f_plugins==0){ ?>plugins<?php } ?><br /> <?php if($f_uploadfile==0){ ?>uploadfile<?php } ?><br /> </p> <p>请将不可写的目录设置为可写(777)权限。</p> <p><a class="button" href="index.php">设置完毕,点击刷新</a></p> <?php }else{ ?> <p class="step"><a class="button" href="index.php?install=next">点击开始安装!</a></p> <?php } ?> </div> </div> <?php include 'footer.html'; ?>
12ik
trunk/install/html/index.html
HTML
oos
4,236
{include file='header.html'} <style> .main{ background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #DFDFDF; border-radius: 11px 11px 11px 11px; color: #333333; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; margin: 2em auto; padding: 1em 2em; width: 700px; } p, li, dd, dt { font-size: 12px; line-height: 18px; padding-bottom: 2px; } .step { margin: 20px 0 15px; } .step, th { padding: 0; text-align: left; } .submit input, .button, .button-secondary { -moz-box-sizing: content-box; border: 1px solid #BBBBBB; border-radius: 15px 15px 15px 15px; color: #464646; cursor: pointer; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 14px !important; line-height: 16px; padding: 6px 12px; text-decoration: none; } .button:hover, .button-secondary:hover, .submit input:hover { border-color: #666666; color: #000000; } .button, .submit input, .button-secondary { background:#F2F2F2; } .button:active, .submit input:active, .button-secondary:active { background: #EEEEEE; } .form-table { border-collapse: collapse; margin-top: 1em; width: 100%; } .form-table td { border-bottom: 8px solid #FFFFFF; font-size: 12px; margin-bottom: 9px; padding: 10px; } .form-table th { border-bottom: 8px solid #FFFFFF; font-size: 13px; padding: 16px 10px 10px; text-align: left; vertical-align: top; width: 130px; } .form-table tr { background: none repeat scroll 0 0 #F3F3F3; } .form-table code { font-size: 18px; line-height: 18px; } .form-table p { font-size: 11px; margin: 4px 0 0; } .form-table input { font-size: 15px; line-height: 20px; padding: 2px; } .form-table th p { font-weight: normal; } #error-page { margin-top: 50px; } #error-page p { font-size: 12px; line-height: 18px; margin: 25px 0 20px; } #error-page code, .code { font-family: Consolas,Monaco,Courier,monospace; } #pass-strength-result { background-color: #EEEEEE; border-color: #DDDDDD !important; border-style: solid; border-width: 1px; display: none; margin: 5px 5px 5px 1px; padding: 5px; text-align: center; width: 200px; } #pass-strength-result.bad { background-color: #FFB78C; border-color: #FF853C !important; } #pass-strength-result.good { background-color: #FFEC8B; border-color: #FFCC00 !important; } #pass-strength-result.short { background-color: #FFA0A0; border-color: #F04040 !important; } #pass-strength-result.strong { background-color: #C3FF88; border-color: #8DFF1C !important; } .message { background-color: #FFFFE0; border: 1px solid #E6DB55; margin: 5px 0 15px; padding: 0.3em 0.6em; } </style> <!--main--> <div class="midder"> <div class="main"> <p> </p><h1>数据库连接错误</h1> <p>您在 <code>config.inc.php</code> 文件中提供的数据库用户名和密码可能不正确,或者无法连接到 <code>localhost</code> 上数据库服务器,这意味着您的主机数据库服务器已停止工作。</p> <ul> <li>您确认您提供的用户名和密码正确么?</li> <li>您确认您提供的主机名正确么?</li> <li>您确认数据库服务器正常运行么?</li> </ul> <p>如果您无法确定这些问题,请联系您的主机管理员。如果您仍需帮助,请访问 <a href="http://www.12ik.com">12ik爱客新社区</a>。</p> <p class="step"><a class="button" onclick="javascript:history.go(-1);return false;" href="#">重试</a></p><p></p> </div> </div> {include file='footer.html'}
12ik
trunk/install/html/error.html
HTML
oos
3,846
<!--footer--> <div class="footer">Powered by <a href="<?php echo $IK_SOFT[info][url]; ?>"><?php echo $IK_SOFT[info][name]; ?></a> <?php echo $IK_SOFT[info][version]; ?> <?php echo $IK_SOFT[info][year]; ?> </div> </body> </html>
12ik
trunk/install/html/footer.html
HTML
oos
235
<?php include 'header.html'; ?> <style> h1 { border-bottom: 1px solid #DADADA; clear: both; color: #666666; font: 24px Georgia,"Times New Roman",Times,serif; margin: 5px 0 0 -4px; padding: 0 0 7px; } .main{ background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #DFDFDF; border-radius: 11px 11px 11px 11px; color: #333333; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; margin: 2em auto; padding: 1em 2em; width: 700px; } p, li, dd, dt { font-size: 12px; line-height: 18px; padding-bottom: 2px; } .step { margin: 20px 0 15px; } .step, th { padding: 0; text-align: left; } .submit input, .button, .button-secondary { -moz-box-sizing: content-box; border: 1px solid #BBBBBB; border-radius: 15px 15px 15px 15px; color: #464646; cursor: pointer; font-family: "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 14px !important; line-height: 16px; padding: 6px 12px; text-decoration: none; } .button:hover, .button-secondary:hover, .submit input:hover { border-color: #666666; color: #000000; } .button, .submit input, .button-secondary { background:#F2F2F2; } .button:active, .submit input:active, .button-secondary:active { background: #EEEEEE; } .form-table { border-collapse: collapse; margin-top: 1em; width: 100%; } .form-table td { border-bottom: 8px solid #FFFFFF; font-size: 12px; margin-bottom: 9px; padding: 10px; } .form-table th { border-bottom: 8px solid #FFFFFF; font-size: 13px; padding: 16px 10px 10px; text-align: left; vertical-align: top; width: 130px; } .form-table tr { background: none repeat scroll 0 0 #F3F3F3; } .form-table code { font-size: 18px; line-height: 18px; } .form-table p { font-size: 11px; margin: 4px 0 0; } .form-table input { font-size: 15px; line-height: 20px; padding: 2px; } .form-table th p { font-weight: normal; } #error-page { margin-top: 50px; } #error-page p { font-size: 12px; line-height: 18px; margin: 25px 0 20px; } #error-page code, .code { font-family: Consolas,Monaco,Courier,monospace; } #pass-strength-result { background-color: #EEEEEE; border-color: #DDDDDD !important; border-style: solid; border-width: 1px; display: none; margin: 5px 5px 5px 1px; padding: 5px; text-align: center; width: 200px; } #pass-strength-result.bad { background-color: #FFB78C; border-color: #FF853C !important; } #pass-strength-result.good { background-color: #FFEC8B; border-color: #FFCC00 !important; } #pass-strength-result.short { background-color: #FFA0A0; border-color: #F04040 !important; } #pass-strength-result.strong { background-color: #C3FF88; border-color: #8DFF1C !important; } .message { background-color: #FFFFE0; border: 1px solid #E6DB55; margin: 5px 0 15px; padding: 0.3em 0.6em; } </style> <!--main--> <div class="midder"> <div class="main"> <h1>完成!</h1> <p>12ik(爱客网) 网站程序安装完成。您是否还沉浸在愉悦的安装过程中?很遗憾,一切皆已完成! :)</p> <table class="form-table"> <tbody><tr> <th>登录Email:</th> <td><code><?php echo $email;?> </code></td> </tr> <tr> <th>登录密码:</th> <td><code><?php echo $password; ?></code></td> </tr> </tbody></table> <p class="step"><a class="button" href="index.php">进入前台</a> <a class="button" href="index.php?app=system">进入后台</a></p> </div> </div> <?php include 'footer.html'; ?>
12ik
trunk/install/html/result.html
HTML
oos
3,826
/**框架CSS**/ body { margin: 0; padding: 0; font-family: Arial; font-size: 12px; text-align: left; } img { border: 0; } h2 { font-size: 14px; padding: 5px; margin: 0px; } a { color: #336699; text-decoration: none; } /*头部*/ .header { background: #3A81C0; width: 100%; overflow: hidden; } .header .head { width: 960px; height: 60px; margin: 0 auto; overflow: hidden; } .header .head .logo { float: left; margin: 10px 0 0 0; color: #FFFFFF; } .header .head .menu { float: right; margin: 20px 0 0 0; color: #FFFFFF; } /*中部*/ .midder { width: 960px; margin: 0 auto; overflow: hidden; } /*底部*/ .footer { background: #F0F0F0; padding: 10px 0; text-align: center; color: #999999; }
12ik
trunk/install/skins/style.css
CSS
oos
727
<?php echo phpinfo();
12ik
trunk/info.php
PHP
oos
23
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12ik爱客网 数据库程序 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ class MySql { public $queryCount = 0; public $conn; public $result; //构造函数 //$IK_DB 数据库链接参数 function __construct($IK_DB) { if (! function_exists ( 'mysql_connect' )) { qiMsg ( '服务器PHP不支持MySql数据库' ); } if ($IK_DB ['host'] && $IK_DB ['user']) { if (! $this->conn = mysql_connect ( $IK_DB ['host'] . ':' . $IK_DB ['port'], $IK_DB ['user'], $IK_DB ['pwd'] )) { qiMsg ( "连接数据库失败,可能是数据库用户名或密码错误" ); } } $this->query ( "SET NAMES 'utf8'" ); if ($IK_DB ['name']) mysql_select_db ( $IK_DB ['name'], $this->conn ) or qiMsg ( "未找到指定数据库,请检查数据是否存在?" ); } /** * 对特殊字符进行过滤 * * @param value 值 */ public function escape($value) { if (is_null ( $value )) return 'NULL'; if (is_bool ( $value )) return $value ? 1 : 0; if (is_int ( $value )) return ( int ) $value; if (is_float ( $value )) return ( float ) $value; if (@get_magic_quotes_gpc ()) $value = stripslashes ( $value ); return '\'' . mysql_real_escape_string ( $value, $this->conn ) . '\''; } /** * 格式化带limit的SQL语句 */ public function setlimit($sql, $limit) { return $sql . " LIMIT {$limit}"; } /* *发送查询语句 */ function query($sql) { $this->result = mysql_query ( $sql, $this->conn ); $this->queryCount ++; if (! $this->result) { qiMsg ( "SQL语句执行错误:$sql <br />" . mysql_error () ); } else { return $this->result; } } /* *fetch_all_assoc */ function fetch_all_assoc($sql, $max = 0) { $query = $this->query ( $sql ); while ( $list_item = mysql_fetch_assoc ( $query ) ) { $current_index ++; if ($current_index > $max && $max != 0) { break; } $all_array [] = $list_item; } return $all_array; } function once_fetch_assoc($sql) { $list = $this->query ( $sql ); $list_array = mysql_fetch_assoc ( $list ); return $list_array; } /* *获取行的数目 */ function once_num_rows($sql) { $query = $this->query ( $sql ); return mysql_num_rows ( $query ); } /* *获得结果集中字段的数目 */ function num_fields($query) { return mysql_num_fields ( $query ); } /* *取得上一步INSERT产生的ID */ function insert_id() { return mysql_insert_id ( $this->conn ); } /* *数组添加 */ function insertArr($arrData, $table, $where = '') { $Item = array (); foreach ( $arrData as $key => $data ) { $Item [] = "$key='$data'"; } $intStr = implode ( ',', $Item ); $sql = "insert into $table SET $intStr $where"; //echo $sql; $this->query ( "insert into $table SET $intStr $where" ); return mysql_insert_id ( $this->conn ); } /* *数组更新(Update) */ function updateArr($arrData, $table, $where = '') { $Item = array (); foreach ( $arrData as $key => $date ) { $Item [] = "$key='$date'"; } $upStr = implode ( ',', $Item ); $this->query ( "UPDATE $table SET $upStr $where" ); return true; } /* *获取mysql错误 */ function geterror() { return mysql_error (); } /* *Get number of affected rows in previous MySQL operation */ function affected_rows() { return mysql_affected_rows (); } /* *获取数据库版本信息 */ function getMysqlVersion() { return @mysql_get_server_info (); } public function __destruct() { return mysql_close ( $this->conn ); } }
12ik
trunk/core/sql/mysql.php
PHP
oos
3,891
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 爱客网 网站核心文件 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ if (substr ( PHP_VERSION, 0, 1 ) != '5') exit ( "网站运行环境要求PHP5!" ); error_reporting ( E_ALL & ~ E_NOTICE & ~ E_WARNING ); @set_magic_quotes_runtime ( 0 ); session_start (); //前台用户基本数据,$IK_USER数组 $IK_USER = array ('user' => isset ( $_SESSION ['tsuser'] ) ? $_SESSION ['tsuser'] : '', 'admin' => isset ( $_SESSION ['tsadmin'] ) ? $_SESSION ['tsadmin'] : '' ); //加载基础函数 require_once 'IKFunction.php'; //开始处理url路由 reurl (); //处理过滤 if (! get_magic_quotes_gpc ()) { Add_S ( $_POST ); Add_S ( $_GET ); } /* *过滤post,get */ function Add_S(&$array) { if (is_array ( $array )) { foreach ( $array as $key => $value ) { if (! is_array ( $value )) { $array [$key] = addslashes ( $value ); } else { Add_S ( $array [$key] ); } } } } //系统Url参数变量 //APP专用 $app = isset($_GET['app']) ? $_GET['app'] : 'home'; //Action专用 $ac = isset($_GET['ac']) ? $_GET['ac'] : 'index'; //安装 $install = isset($_GET['install']) ? $_GET['install'] : 'index'; //ThinkSAAS专用 $ts = isset($_GET['ts']) ? $_GET['ts'] : ''; //Admin管理专用 $mg = isset($_GET['mg']) ? $_GET['mg'] : 'index'; //Api专用 $api = isset($_GET['api']) ? $_GET['api'] : 'index'; //plugin专用 $plugin = isset($_GET['plugin']) ? $_GET['plugin'] : ''; //plugin专用 $in = isset($_GET['in']) ? $_GET['in'] : ''; //处理html编码 header('Content-Type: text/html; charset=UTF-8'); //安装配置文件,数据库配置判断 if(!is_file('data/config.inc.php')){ require_once 'install/index.php';exit; } //数据库配置文件 require_once 'data/config.inc.php'; //连接数据库 require_once 'sql/'.$IK_DB['sql'].'.php'; $db = new MySql($IK_DB); //加载APP数据库操作类并建立对象 require_once 'IKApp.php'; //加载软件信息 $IK_SOFT ['info'] = array ('name' => '12IK', 'version' => '1.0', 'url' => 'http://www.12ik.com/', 'email' => '160780470@qq.com', 'copyright' => '12ik.com', 'year' => '2012 - 2015', 'author' => '小麦' );
12ik
trunk/core/core.php
PHP
oos
2,301
<?php ///////////////////////////////////////////////////////////////// // 12IK爱客网中文社区, Copyright (C) 2012 - 2015 12IK.COM // ///////////////////////////////////////////////////////////////// defined ( 'IN_IK' ) or die ( 'Access Denied.' ); class IKApp { public $db; public function __construct($dbhandle) { $this->db = $dbhandle; } /** * 在数据表中新增一行数据 * * @param row 数组形式,数组的键是数据表中的字段名,键对应的值是需要新增的数据。 */ public function create($table, $row) { if (! is_array ( $row )) return FALSE; if (empty ( $row )) return FALSE; foreach ( $row as $key => $value ) { $cols [] = $key; $vals [] = $this->escape ( $value ); } $col = join ( ',', $cols ); $val = join ( ',', $vals ); $sql = "INSERT INTO " . dbprefix . "{$table} ({$col}) VALUES ({$val})"; if (FALSE != $this->db->query ( $sql )) { // 获取当前新增的ID if ($newinserid = $this->db->insert_id ()) { return $newinserid; } } return FALSE; } /** * 替换数据,根据条件替换存在的记录,如记录不存在,则将条件与替换数据相加并新增一条记录。 * @param table 数据表 * @param conditions 数组形式,查找条件,请注意,仅能使用数组作为该条件! * @param row 数组形式,修改的数据 */ public function replace($table, $conditions, $row) { if ($this->find ( $conditions )) { return $this->update ( $table, $conditions, $row ); } else { if (! is_array ( $conditions )) tsMsg ( 'replace方法的条件务必是数组形式!' ); return $this->create ( $table, $rows ); } } /** * 修改数据,该函数将根据参数中设置的条件而更新表中数据 * @param table 数据表 * @param conditions 数组形式,查找条件,此参数的格式用法与find/findAll的查找条件参数是相同的。 * @param row 数组形式,修改的数据, * 此参数的格式用法与create的$row是相同的。在符合条件的记录中,将对$row设置的字段的数据进行修改。 * 例子: * $new['group']->update('group',array('groupid'=>$groupid,),array('path'=>$arrUpload['path'])); */ public function update($table, $conditions, $row) { $where = ""; //$row = $this->__prepera_format($row); if (empty ( $row )) return FALSE; if (is_array ( $conditions )) { $join = array (); foreach ( $conditions as $key => $condition ) { $condition = $this->escape ( $condition ); $join [] = "{$key} = {$condition}"; } $where = "WHERE " . join ( " AND ", $join ); } else { if (null != $conditions) $where = "WHERE " . $conditions; } foreach ( $row as $key => $value ) { $value = $this->escape ( $value ); $vals [] = "{$key} = {$value}"; } $values = join ( ", ", $vals ); $sql = "UPDATE " . dbprefix . "{$table} SET {$values} {$where}"; return $this->db->query ( $sql ); } /** * 按条件删除记录 * @param table * @param conditions 数组形式,查找条件,此参数的格式用法与find/findAll的查找条件参数是相同的。 */ public function delete($table, $conditions) { $where = ""; if (is_array ( $conditions )) { $join = array (); foreach ( $conditions as $key => $condition ) { $condition = $this->escape ( $condition ); $join [] = "{$key} = {$condition}"; } $where = "WHERE ( " . join ( " AND ", $join ) . ")"; } else { if (null != $conditions) $where = "WHERE ( " . $conditions . ")"; } $sql = "DELETE FROM " . dbprefix . "{$table} {$where}"; return $this->db->query ( $sql ); } /** * 从数据表中查找一条记录 * @param table 数据表 * @param conditions 查找条件,数组array("字段名"=>"查找值")或字符串, * 请注意在使用字符串时将需要开发者自行使用escape来对输入值进行过滤 * @param fields 返回的字段范围,默认为返回全部字段的值 * @param sort 排序,等同于“ORDER BY ” */ public function find($table, $conditions = null, $fields = null, $sort = null) { if ($record = $this->findAll ( $table, $conditions, $sort, $fields, 1 )) { return array_pop ( $record ); } else { return FALSE; } } /** * 从数据表中查找记录 * @param table 数据表 * @param conditions 查找条件,数组array("字段名"=>"查找值")或字符串, * 请注意在使用字符串时将需要开发者自行使用escape来对输入值进行过滤 * @param sort 排序,等同于“ORDER BY ” * @param fields 返回的字段范围,默认为返回全部字段的值 * @param limit 返回的结果数量限制,等同于“LIMIT ”,如$limit = " 3, 5",即是从第3条记录(从0开始计算)开始获取,共获取5条记录 * 如果limit值只有一个数字,则是指代从0条记录开始。 */ public function findAll($table, $conditions = null, $sort = null, $fields = null, $limit = null) { $where = ""; $fields = empty ( $fields ) ? "*" : $fields; if (is_array ( $conditions )) { $join = array (); foreach ( $conditions as $key => $condition ) { $condition = $this->escape ( $condition ); $join [] = "{$key} = {$condition}"; } $where = "WHERE " . join ( " AND ", $join ); } else { if (null != $conditions) $where = "WHERE " . $conditions; } if (null != $sort) { $sort = "ORDER BY {$sort}"; } else { $sort = ""; } $sql = "SELECT {$fields} FROM " . dbprefix . "{$table} {$where} {$sort}"; if (null != $limit) $sql = $this->db->setlimit ( $sql, $limit ); return $this->db->fetch_all_assoc ( $sql ); } /** * 过滤转义字符 * * @param value 需要进行过滤的值 */ public function escape($value) { return $this->db->escape ( $value ); } /** * 计算符合条件的记录数量 * @param table 数据表 * @param conditions 查找条件,数组array("字段名"=>"查找值")或字符串, * 请注意在使用字符串时将需要开发者自行使用escape来对输入值进行过滤 */ public function findCount($table, $conditions = null) { $where = ""; if (is_array ( $conditions )) { $join = array (); foreach ( $conditions as $key => $condition ) { $condition = $this->escape ( $condition ); $join [] = "{$key} = {$condition}"; } $where = "WHERE " . join ( " AND ", $join ); } else { if (null != $conditions) $where = "WHERE " . $conditions; } $sql = "SELECT COUNT(*) AS IK_COUNTER FROM " . dbprefix . "{$table} {$where}"; $result = $this->db->once_fetch_assoc ( $sql ); return $result ['IK_COUNTER']; } }
12ik
trunk/core/IKApp.php
PHP
oos
6,905
<?php /*~ class.phpmailer.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | | Version: 5.1 | | Contact: via sourceforge.net support pages (also www.worxware.com) | | Info: http://phpmailer.sourceforge.net | | Support: http://sourceforge.net/projects/phpmailer/ | | ------------------------------------------------------------------------- | | Admin: Andy Prevost (project admininistrator) | | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | | Founder: Brent R. Matzelle (original founder) | | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | | License: Distributed under the Lesser General Public License (LGPL) | | http://www.gnu.org/copyleft/lesser.html | | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | | ------------------------------------------------------------------------- | | We offer a number of paid services (www.worxware.com): | | - Web Hosting on highly optimized fast and secure servers | | - Technology Consulting | | - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' */ /** * PHPMailer - PHP email transport class * NOTE: Requires PHP version 5 or later * @package PHPMailer * @author Andy Prevost * @author Marcus Bointon * @copyright 2004 - 2009 Andy Prevost * @version $Id: class.phpmailer.php 208 2011-10-21 17:24:48Z wanglijun $ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License */ if (version_compare ( PHP_VERSION, '5.0.0', '<' )) exit ( "Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n" ); class PHPMailer { ///////////////////////////////////////////////// // PROPERTIES, PUBLIC ///////////////////////////////////////////////// /** * Email priority (1 = High, 3 = Normal, 5 = low). * @var int */ public $Priority = 3; /** * Sets the CharSet of the message. * @var string */ public $CharSet = 'iso-8859-1'; /** * Sets the Content-type of the message. * @var string */ public $ContentType = 'text/plain'; /** * Sets the Encoding of the message. Options for this are * "8bit", "7bit", "binary", "base64", and "quoted-printable". * @var string */ public $Encoding = '8bit'; /** * Holds the most recent mailer error message. * @var string */ public $ErrorInfo = ''; /** * Sets the From email address for the message. * @var string */ public $From = 'root@localhost'; /** * Sets the From name of the message. * @var string */ public $FromName = 'Root User'; /** * Sets the Sender email (Return-Path) of the message. If not empty, * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. * @var string */ public $Sender = ''; /** * Sets the Subject of the message. * @var string */ public $Subject = ''; /** * Sets the Body of the message. This can be either an HTML or text body. * If HTML then run IsHTML(true). * @var string */ public $Body = ''; /** * Sets the text-only body of the message. This automatically sets the * email to multipart/alternative. This body can be read by mail * clients that do not have HTML email capability such as mutt. Clients * that can read HTML will view the normal Body. * @var string */ public $AltBody = ''; /** * Sets word wrapping on the body of the message to a given number of * characters. * @var int */ public $WordWrap = 0; /** * Method to send mail: ("mail", "sendmail", or "smtp"). * @var string */ public $Mailer = 'mail'; /** * Sets the path of the sendmail program. * @var string */ public $Sendmail = '/usr/sbin/sendmail'; /** * Path to PHPMailer plugins. Useful if the SMTP class * is in a different directory than the PHP include path. * @var string */ public $PluginDir = ''; /** * Sets the email address that a reading confirmation will be sent. * @var string */ public $ConfirmReadingTo = ''; /** * Sets the hostname to use in Message-Id and Received headers * and as default HELO string. If empty, the value returned * by SERVER_NAME is used or 'localhost.localdomain'. * @var string */ public $Hostname = ''; /** * Sets the message ID to be used in the Message-Id header. * If empty, a unique id will be generated. * @var string */ public $MessageID = ''; ///////////////////////////////////////////////// // PROPERTIES FOR SMTP ///////////////////////////////////////////////// /** * Sets the SMTP hosts. All hosts must be separated by a * semicolon. You can also specify a different port * for each host by using this format: [hostname:port] * (e.g. "smtp1.example.com:25;smtp2.example.com"). * Hosts will be tried in order. * @var string */ public $Host = 'localhost'; /** * Sets the default SMTP server port. * @var int */ public $Port = 25; /** * Sets the SMTP HELO of the message (Default is $Hostname). * @var string */ public $Helo = ''; /** * Sets connection prefix. * Options are "", "ssl" or "tls" * @var string */ public $SMTPSecure = ''; /** * Sets SMTP authentication. Utilizes the Username and Password variables. * @var bool */ public $SMTPAuth = false; /** * Sets SMTP username. * @var string */ public $Username = ''; /** * Sets SMTP password. * @var string */ public $Password = ''; /** * Sets the SMTP server timeout in seconds. * This function will not work with the win32 version. * @var int */ public $Timeout = 10; /** * Sets SMTP class debugging on or off. * @var bool */ public $SMTPDebug = false; /** * Prevents the SMTP connection from being closed after each mail * sending. If this is set to true then to close the connection * requires an explicit call to SmtpClose(). * @var bool */ public $SMTPKeepAlive = false; /** * Provides the ability to have the TO field process individual * emails, instead of sending to entire TO addresses * @var bool */ public $SingleTo = false; /** * If SingleTo is true, this provides the array to hold the email addresses * @var bool */ public $SingleToArray = array (); /** * Provides the ability to change the line ending * @var string */ public $LE = "\n"; /** * Used with DKIM DNS Resource Record * @var string */ public $DKIM_selector = 'phpmailer'; /** * Used with DKIM DNS Resource Record * optional, in format of email address 'you@yourdomain.com' * @var string */ public $DKIM_identity = ''; /** * Used with DKIM DNS Resource Record * optional, in format of email address 'you@yourdomain.com' * @var string */ public $DKIM_domain = ''; /** * Used with DKIM DNS Resource Record * optional, in format of email address 'you@yourdomain.com' * @var string */ public $DKIM_private = ''; /** * Callback Action function name * the function that handles the result of the send email action. Parameters: * bool $result result of the send action * string $to email address of the recipient * string $cc cc email addresses * string $bcc bcc email addresses * string $subject the subject * string $body the email body * @var string */ public $action_function = ''; //'callbackAction'; /** * Sets the PHPMailer Version number * @var string */ public $Version = '5.1'; ///////////////////////////////////////////////// // PROPERTIES, PRIVATE AND PROTECTED ///////////////////////////////////////////////// private $smtp = NULL; private $to = array (); private $cc = array (); private $bcc = array (); private $ReplyTo = array (); private $all_recipients = array (); private $attachment = array (); private $CustomHeader = array (); private $message_type = ''; private $boundary = array (); protected $language = array (); private $error_count = 0; private $sign_cert_file = ""; private $sign_key_file = ""; private $sign_key_pass = ""; private $exceptions = false; ///////////////////////////////////////////////// // CONSTANTS ///////////////////////////////////////////////// const STOP_MESSAGE = 0; // message only, continue processing const STOP_CONTINUE = 1; // message?, likely ok to continue processing const STOP_CRITICAL = 2; // message, plus full stop, critical error reached ///////////////////////////////////////////////// // METHODS, VARIABLES ///////////////////////////////////////////////// /** * Constructor * @param boolean $exceptions Should we throw external exceptions? */ public function __construct($exceptions = false) { $this->exceptions = ($exceptions == true); } /** * Sets message type to HTML. * @param bool $ishtml * @return void */ public function IsHTML($ishtml = true) { if ($ishtml) { $this->ContentType = 'text/html'; } else { $this->ContentType = 'text/plain'; } } /** * Sets Mailer to send message using SMTP. * @return void */ public function IsSMTP() { $this->Mailer = 'smtp'; } /** * Sets Mailer to send message using PHP mail() function. * @return void */ public function IsMail() { $this->Mailer = 'mail'; } /** * Sets Mailer to send message using the $Sendmail program. * @return void */ public function IsSendmail() { if (! stristr ( ini_get ( 'sendmail_path' ), 'sendmail' )) { $this->Sendmail = '/var/qmail/bin/sendmail'; } $this->Mailer = 'sendmail'; } /** * Sets Mailer to send message using the qmail MTA. * @return void */ public function IsQmail() { if (stristr ( ini_get ( 'sendmail_path' ), 'qmail' )) { $this->Sendmail = '/var/qmail/bin/sendmail'; } $this->Mailer = 'sendmail'; } ///////////////////////////////////////////////// // METHODS, RECIPIENTS ///////////////////////////////////////////////// /** * Adds a "To" address. * @param string $address * @param string $name * @return boolean true on success, false if address already used */ public function AddAddress($address, $name = '') { return $this->AddAnAddress ( 'to', $address, $name ); } /** * Adds a "Cc" address. * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. * @param string $address * @param string $name * @return boolean true on success, false if address already used */ public function AddCC($address, $name = '') { return $this->AddAnAddress ( 'cc', $address, $name ); } /** * Adds a "Bcc" address. * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. * @param string $address * @param string $name * @return boolean true on success, false if address already used */ public function AddBCC($address, $name = '') { return $this->AddAnAddress ( 'bcc', $address, $name ); } /** * Adds a "Reply-to" address. * @param string $address * @param string $name * @return boolean */ public function AddReplyTo($address, $name = '') { return $this->AddAnAddress ( 'ReplyTo', $address, $name ); } /** * Adds an address to one of the recipient arrays * Addresses that have been added already return false, but do not throw exceptions * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo' * @param string $address The email address to send to * @param string $name * @return boolean true on success, false if address already used or invalid in some way * @access private */ private function AddAnAddress($kind, $address, $name = '') { if (! preg_match ( '/^(to|cc|bcc|ReplyTo)$/', $kind )) { echo 'Invalid recipient array: ' . kind; return false; } $address = trim ( $address ); $name = trim ( preg_replace ( '/[\r\n]+/', '', $name ) ); //Strip breaks and trim if (! self::ValidateAddress ( $address )) { $this->SetError ( $this->Lang ( 'invalid_address' ) . ': ' . $address ); if ($this->exceptions) { throw new phpmailerException ( $this->Lang ( 'invalid_address' ) . ': ' . $address ); } echo $this->Lang ( 'invalid_address' ) . ': ' . $address; return false; } if ($kind != 'ReplyTo') { if (! isset ( $this->all_recipients [strtolower ( $address )] )) { array_push ( $this->$kind, array ($address, $name ) ); $this->all_recipients [strtolower ( $address )] = true; return true; } } else { if (! array_key_exists ( strtolower ( $address ), $this->ReplyTo )) { $this->ReplyTo [strtolower ( $address )] = array ($address, $name ); return true; } } return false; } /** * Set the From and FromName properties * @param string $address * @param string $name * @return boolean */ public function SetFrom($address, $name = '', $auto = 1) { $address = trim ( $address ); $name = trim ( preg_replace ( '/[\r\n]+/', '', $name ) ); //Strip breaks and trim if (! self::ValidateAddress ( $address )) { $this->SetError ( $this->Lang ( 'invalid_address' ) . ': ' . $address ); if ($this->exceptions) { throw new phpmailerException ( $this->Lang ( 'invalid_address' ) . ': ' . $address ); } echo $this->Lang ( 'invalid_address' ) . ': ' . $address; return false; } $this->From = $address; $this->FromName = $name; if ($auto) { if (empty ( $this->ReplyTo )) { $this->AddAnAddress ( 'ReplyTo', $address, $name ); } if (empty ( $this->Sender )) { $this->Sender = $address; } } return true; } /** * Check that a string looks roughly like an email address should * Static so it can be used without instantiation * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator * Conforms approximately to RFC2822 * @link http://www.hexillion.com/samples/#Regex Original pattern found here * @param string $address The email address to check * @return boolean * @static * @access public */ public static function ValidateAddress($address) { if (function_exists ( 'filter_var' )) { //Introduced in PHP 5.2 if (filter_var ( $address, FILTER_VALIDATE_EMAIL ) === FALSE) { return false; } else { return true; } } else { return preg_match ( '/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address ); } } ///////////////////////////////////////////////// // METHODS, MAIL SENDING ///////////////////////////////////////////////// /** * Creates message and assigns Mailer. If the message is * not sent successfully then it returns false. Use the ErrorInfo * variable to view description of the error. * @return bool */ public function Send() { try { if ((count ( $this->to ) + count ( $this->cc ) + count ( $this->bcc )) < 1) { throw new phpmailerException ( $this->Lang ( 'provide_address' ), self::STOP_CRITICAL ); } // Set whether the message is multipart/alternative if (! empty ( $this->AltBody )) { $this->ContentType = 'multipart/alternative'; } $this->error_count = 0; // reset errors $this->SetMessageType (); $header = $this->CreateHeader (); $body = $this->CreateBody (); if (empty ( $this->Body )) { throw new phpmailerException ( $this->Lang ( 'empty_message' ), self::STOP_CRITICAL ); } // digitally sign with DKIM if enabled if ($this->DKIM_domain && $this->DKIM_private) { $header_dkim = $this->DKIM_Add ( $header, $this->Subject, $body ); $header = str_replace ( "\r\n", "\n", $header_dkim ) . $header; } // Choose the mailer and send through it switch ($this->Mailer) { case 'sendmail' : return $this->SendmailSend ( $header, $body ); case 'smtp' : return $this->SmtpSend ( $header, $body ); default : return $this->MailSend ( $header, $body ); } } catch ( phpmailerException $e ) { $this->SetError ( $e->getMessage () ); if ($this->exceptions) { throw $e; } echo $e->getMessage () . "\n"; return false; } } /** * Sends mail using the $Sendmail program. * @param string $header The message headers * @param string $body The message body * @access protected * @return bool */ protected function SendmailSend($header, $body) { if ($this->Sender != '') { $sendmail = sprintf ( "%s -oi -f %s -t", escapeshellcmd ( $this->Sendmail ), escapeshellarg ( $this->Sender ) ); } else { $sendmail = sprintf ( "%s -oi -t", escapeshellcmd ( $this->Sendmail ) ); } if ($this->SingleTo === true) { foreach ( $this->SingleToArray as $key => $val ) { if (! @$mail = popen ( $sendmail, 'w' )) { throw new phpmailerException ( $this->Lang ( 'execute' ) . $this->Sendmail, self::STOP_CRITICAL ); } fputs ( $mail, "To: " . $val . "\n" ); fputs ( $mail, $header ); fputs ( $mail, $body ); $result = pclose ( $mail ); // implement call back function if it exists $isSent = ($result == 0) ? 1 : 0; $this->doCallback ( $isSent, $val, $this->cc, $this->bcc, $this->Subject, $body ); if ($result != 0) { throw new phpmailerException ( $this->Lang ( 'execute' ) . $this->Sendmail, self::STOP_CRITICAL ); } } } else { if (! @$mail = popen ( $sendmail, 'w' )) { throw new phpmailerException ( $this->Lang ( 'execute' ) . $this->Sendmail, self::STOP_CRITICAL ); } fputs ( $mail, $header ); fputs ( $mail, $body ); $result = pclose ( $mail ); // implement call back function if it exists $isSent = ($result == 0) ? 1 : 0; $this->doCallback ( $isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body ); if ($result != 0) { throw new phpmailerException ( $this->Lang ( 'execute' ) . $this->Sendmail, self::STOP_CRITICAL ); } } return true; } /** * Sends mail using the PHP mail() function. * @param string $header The message headers * @param string $body The message body * @access protected * @return bool */ protected function MailSend($header, $body) { $toArr = array (); foreach ( $this->to as $t ) { $toArr [] = $this->AddrFormat ( $t ); } $to = implode ( ', ', $toArr ); $params = sprintf ( "-oi -f %s", $this->Sender ); if ($this->Sender != '' && strlen ( ini_get ( 'safe_mode' ) ) < 1) { $old_from = ini_get ( 'sendmail_from' ); ini_set ( 'sendmail_from', $this->Sender ); if ($this->SingleTo === true && count ( $toArr ) > 1) { foreach ( $toArr as $key => $val ) { $rt = @mail ( $val, $this->EncodeHeader ( $this->SecureHeader ( $this->Subject ) ), $body, $header, $params ); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; $this->doCallback ( $isSent, $val, $this->cc, $this->bcc, $this->Subject, $body ); } } else { $rt = @mail ( $to, $this->EncodeHeader ( $this->SecureHeader ( $this->Subject ) ), $body, $header, $params ); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; $this->doCallback ( $isSent, $to, $this->cc, $this->bcc, $this->Subject, $body ); } } else { if ($this->SingleTo === true && count ( $toArr ) > 1) { foreach ( $toArr as $key => $val ) { $rt = @mail ( $val, $this->EncodeHeader ( $this->SecureHeader ( $this->Subject ) ), $body, $header, $params ); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; $this->doCallback ( $isSent, $val, $this->cc, $this->bcc, $this->Subject, $body ); } } else { $rt = @mail ( $to, $this->EncodeHeader ( $this->SecureHeader ( $this->Subject ) ), $body, $header ); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; $this->doCallback ( $isSent, $to, $this->cc, $this->bcc, $this->Subject, $body ); } } if (isset ( $old_from )) { ini_set ( 'sendmail_from', $old_from ); } if (! $rt) { throw new phpmailerException ( $this->Lang ( 'instantiate' ), self::STOP_CRITICAL ); } return true; } /** * Sends mail via SMTP using PhpSMTP * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. * @param string $header The message headers * @param string $body The message body * @uses SMTP * @access protected * @return bool */ protected function SmtpSend($header, $body) { require_once $this->PluginDir . 'class.smtp.php'; $bad_rcpt = array (); if (! $this->SmtpConnect ()) { throw new phpmailerException ( $this->Lang ( 'smtp_connect_failed' ), self::STOP_CRITICAL ); } $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; if (! $this->smtp->Mail ( $smtp_from )) { throw new phpmailerException ( $this->Lang ( 'from_failed' ) . $smtp_from, self::STOP_CRITICAL ); } // Attempt to send attach all recipients foreach ( $this->to as $to ) { if (! $this->smtp->Recipient ( $to [0] )) { $bad_rcpt [] = $to [0]; // implement call back function if it exists $isSent = 0; $this->doCallback ( $isSent, $to [0], '', '', $this->Subject, $body ); } else { // implement call back function if it exists $isSent = 1; $this->doCallback ( $isSent, $to [0], '', '', $this->Subject, $body ); } } foreach ( $this->cc as $cc ) { if (! $this->smtp->Recipient ( $cc [0] )) { $bad_rcpt [] = $cc [0]; // implement call back function if it exists $isSent = 0; $this->doCallback ( $isSent, '', $cc [0], '', $this->Subject, $body ); } else { // implement call back function if it exists $isSent = 1; $this->doCallback ( $isSent, '', $cc [0], '', $this->Subject, $body ); } } foreach ( $this->bcc as $bcc ) { if (! $this->smtp->Recipient ( $bcc [0] )) { $bad_rcpt [] = $bcc [0]; // implement call back function if it exists $isSent = 0; $this->doCallback ( $isSent, '', '', $bcc [0], $this->Subject, $body ); } else { // implement call back function if it exists $isSent = 1; $this->doCallback ( $isSent, '', '', $bcc [0], $this->Subject, $body ); } } if (count ( $bad_rcpt ) > 0) { //Create error message for any bad addresses $badaddresses = implode ( ', ', $bad_rcpt ); throw new phpmailerException ( $this->Lang ( 'recipients_failed' ) . $badaddresses ); } if (! $this->smtp->Data ( $header . $body )) { throw new phpmailerException ( $this->Lang ( 'data_not_accepted' ), self::STOP_CRITICAL ); } if ($this->SMTPKeepAlive == true) { $this->smtp->Reset (); } return true; } /** * Initiates a connection to an SMTP server. * Returns false if the operation failed. * @uses SMTP * @access public * @return bool */ public function SmtpConnect() { if (is_null ( $this->smtp )) { $this->smtp = new SMTP (); } $this->smtp->do_debug = $this->SMTPDebug; $hosts = explode ( ';', $this->Host ); $index = 0; $connection = $this->smtp->Connected (); // Retry while there is no connection try { while ( $index < count ( $hosts ) && ! $connection ) { $hostinfo = array (); if (preg_match ( '/^(.+):([0-9]+)$/', $hosts [$index], $hostinfo )) { $host = $hostinfo [1]; $port = $hostinfo [2]; } else { $host = $hosts [$index]; $port = $this->Port; } $tls = ($this->SMTPSecure == 'tls'); $ssl = ($this->SMTPSecure == 'ssl'); if ($this->smtp->Connect ( ($ssl ? 'ssl://' : '') . $host, $port, $this->Timeout )) { $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname ()); $this->smtp->Hello ( $hello ); if ($tls) { if (! $this->smtp->StartTLS ()) { throw new phpmailerException ( $this->Lang ( 'tls' ) ); } //We must resend HELO after tls negotiation $this->smtp->Hello ( $hello ); } $connection = true; if ($this->SMTPAuth) { if (! $this->smtp->Authenticate ( $this->Username, $this->Password )) { throw new phpmailerException ( $this->Lang ( 'authenticate' ) ); } } } $index ++; if (! $connection) { throw new phpmailerException ( $this->Lang ( 'connect_host' ) ); } } } catch ( phpmailerException $e ) { $this->smtp->Reset (); throw $e; } return true; } /** * Closes the active SMTP session if one exists. * @return void */ public function SmtpClose() { if (! is_null ( $this->smtp )) { if ($this->smtp->Connected ()) { $this->smtp->Quit (); $this->smtp->Close (); } } } /** * Sets the language for all class error messages. * Returns false if it cannot load the language file. The default language is English. * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br") * @param string $lang_path Path to the language file directory * @access public */ function SetLanguage($langcode = 'en', $lang_path = 'language/') { //Define full set of translatable strings $PHPMAILER_LANG = array ('provide_address' => 'You must provide at least one recipient email address.', 'mailer_not_supported' => ' mailer is not supported.', 'execute' => 'Could not execute: ', 'instantiate' => 'Could not instantiate mail function.', 'authenticate' => 'SMTP Error: Could not authenticate.', 'from_failed' => 'The following From address failed: ', 'recipients_failed' => 'SMTP Error: The following recipients failed: ', 'data_not_accepted' => 'SMTP Error: Data not accepted.', 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', 'file_access' => 'Could not access file: ', 'file_open' => 'File Error: Could not open file: ', 'encoding' => 'Unknown encoding: ', 'signing' => 'Signing Error: ', 'smtp_error' => 'SMTP server error: ', 'empty_message' => 'Message body empty', 'invalid_address' => 'Invalid address', 'variable_set' => 'Cannot set or reset variable: ' ); //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"! $l = true; if ($langcode != 'en') { //There is no English translation file $l = @include $lang_path . 'phpmailer.lang-' . $langcode . '.php'; } $this->language = $PHPMAILER_LANG; return ($l == true); //Returns false if language not found } /** * Return the current array of language strings * @return array */ public function GetTranslations() { return $this->language; } ///////////////////////////////////////////////// // METHODS, MESSAGE CREATION ///////////////////////////////////////////////// /** * Creates recipient headers. * @access public * @return string */ public function AddrAppend($type, $addr) { $addr_str = $type . ': '; $addresses = array (); foreach ( $addr as $a ) { $addresses [] = $this->AddrFormat ( $a ); } $addr_str .= implode ( ', ', $addresses ); $addr_str .= $this->LE; return $addr_str; } /** * Formats an address correctly. * @access public * @return string */ public function AddrFormat($addr) { if (empty ( $addr [1] )) { return $this->SecureHeader ( $addr [0] ); } else { return $this->EncodeHeader ( $this->SecureHeader ( $addr [1] ), 'phrase' ) . " <" . $this->SecureHeader ( $addr [0] ) . ">"; } } /** * Wraps message for use with mailers that do not * automatically perform wrapping and for quoted-printable. * Original written by philippe. * @param string $message The message to wrap * @param integer $length The line length to wrap to * @param boolean $qp_mode Whether to run in Quoted-Printable mode * @access public * @return string */ public function WrapText($message, $length, $qp_mode = false) { $soft_break = ($qp_mode) ? sprintf ( " =%s", $this->LE ) : $this->LE; // If utf-8 encoding is used, we will need to make sure we don't // split multibyte characters when we wrap $is_utf8 = (strtolower ( $this->CharSet ) == "utf-8"); $message = $this->FixEOL ( $message ); if (substr ( $message, - 1 ) == $this->LE) { $message = substr ( $message, 0, - 1 ); } $line = explode ( $this->LE, $message ); $message = ''; for($i = 0; $i < count ( $line ); $i ++) { $line_part = explode ( ' ', $line [$i] ); $buf = ''; for($e = 0; $e < count ( $line_part ); $e ++) { $word = $line_part [$e]; if ($qp_mode and (strlen ( $word ) > $length)) { $space_left = $length - strlen ( $buf ) - 1; if ($e != 0) { if ($space_left > 20) { $len = $space_left; if ($is_utf8) { $len = $this->UTF8CharBoundary ( $word, $len ); } elseif (substr ( $word, $len - 1, 1 ) == "=") { $len --; } elseif (substr ( $word, $len - 2, 1 ) == "=") { $len -= 2; } $part = substr ( $word, 0, $len ); $word = substr ( $word, $len ); $buf .= ' ' . $part; $message .= $buf . sprintf ( "=%s", $this->LE ); } else { $message .= $buf . $soft_break; } $buf = ''; } while ( strlen ( $word ) > 0 ) { $len = $length; if ($is_utf8) { $len = $this->UTF8CharBoundary ( $word, $len ); } elseif (substr ( $word, $len - 1, 1 ) == "=") { $len --; } elseif (substr ( $word, $len - 2, 1 ) == "=") { $len -= 2; } $part = substr ( $word, 0, $len ); $word = substr ( $word, $len ); if (strlen ( $word ) > 0) { $message .= $part . sprintf ( "=%s", $this->LE ); } else { $buf = $part; } } } else { $buf_o = $buf; $buf .= ($e == 0) ? $word : (' ' . $word); if (strlen ( $buf ) > $length and $buf_o != '') { $message .= $buf_o . $soft_break; $buf = $word; } } } $message .= $buf . $this->LE; } return $message; } /** * Finds last character boundary prior to maxLength in a utf-8 * quoted (printable) encoded string. * Original written by Colin Brown. * @access public * @param string $encodedText utf-8 QP text * @param int $maxLength find last character boundary prior to this length * @return int */ public function UTF8CharBoundary($encodedText, $maxLength) { $foundSplitPos = false; $lookBack = 3; while ( ! $foundSplitPos ) { $lastChunk = substr ( $encodedText, $maxLength - $lookBack, $lookBack ); $encodedCharPos = strpos ( $lastChunk, "=" ); if ($encodedCharPos !== false) { // Found start of encoded character byte within $lookBack block. // Check the encoded byte value (the 2 chars after the '=') $hex = substr ( $encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2 ); $dec = hexdec ( $hex ); if ($dec < 128) { // Single byte character. // If the encoded char was found at pos 0, it will fit // otherwise reduce maxLength to start of the encoded char $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos); $foundSplitPos = true; } elseif ($dec >= 192) { // First byte of a multi byte character // Reduce maxLength to split at start of character $maxLength = $maxLength - ($lookBack - $encodedCharPos); $foundSplitPos = true; } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back $lookBack += 3; } } else { // No encoded character found $foundSplitPos = true; } } return $maxLength; } /** * Set the body wrapping. * @access public * @return void */ public function SetWordWrap() { if ($this->WordWrap < 1) { return; } switch ($this->message_type) { case 'alt' : case 'alt_attachments' : $this->AltBody = $this->WrapText ( $this->AltBody, $this->WordWrap ); break; default : $this->Body = $this->WrapText ( $this->Body, $this->WordWrap ); break; } } /** * Assembles message header. * @access public * @return string The assembled header */ public function CreateHeader() { $result = ''; // Set the boundaries $uniq_id = md5 ( uniqid ( time () ) ); $this->boundary [1] = 'b1_' . $uniq_id; $this->boundary [2] = 'b2_' . $uniq_id; $result .= $this->HeaderLine ( 'Date', self::RFCDate () ); if ($this->Sender == '') { $result .= $this->HeaderLine ( 'Return-Path', trim ( $this->From ) ); } else { $result .= $this->HeaderLine ( 'Return-Path', trim ( $this->Sender ) ); } // To be created automatically by mail() if ($this->Mailer != 'mail') { if ($this->SingleTo === true) { foreach ( $this->to as $t ) { $this->SingleToArray [] = $this->AddrFormat ( $t ); } } else { if (count ( $this->to ) > 0) { $result .= $this->AddrAppend ( 'To', $this->to ); } elseif (count ( $this->cc ) == 0) { $result .= $this->HeaderLine ( 'To', 'undisclosed-recipients:;' ); } } } $from = array (); $from [0] [0] = trim ( $this->From ); $from [0] [1] = $this->FromName; $result .= $this->AddrAppend ( 'From', $from ); // sendmail and mail() extract Cc from the header before sending if (count ( $this->cc ) > 0) { $result .= $this->AddrAppend ( 'Cc', $this->cc ); } // sendmail and mail() extract Bcc from the header before sending if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count ( $this->bcc ) > 0)) { $result .= $this->AddrAppend ( 'Bcc', $this->bcc ); } if (count ( $this->ReplyTo ) > 0) { $result .= $this->AddrAppend ( 'Reply-to', $this->ReplyTo ); } // mail() sets the subject itself if ($this->Mailer != 'mail') { $result .= $this->HeaderLine ( 'Subject', $this->EncodeHeader ( $this->SecureHeader ( $this->Subject ) ) ); } if ($this->MessageID != '') { $result .= $this->HeaderLine ( 'Message-ID', $this->MessageID ); } else { $result .= sprintf ( "Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname (), $this->LE ); } $result .= $this->HeaderLine ( 'X-Priority', $this->Priority ); $result .= $this->HeaderLine ( 'X-Mailer', 'PHPMailer ' . $this->Version . ' (phpmailer.sourceforge.net)' ); if ($this->ConfirmReadingTo != '') { $result .= $this->HeaderLine ( 'Disposition-Notification-To', '<' . trim ( $this->ConfirmReadingTo ) . '>' ); } // Add custom headers for($index = 0; $index < count ( $this->CustomHeader ); $index ++) { $result .= $this->HeaderLine ( trim ( $this->CustomHeader [$index] [0] ), $this->EncodeHeader ( trim ( $this->CustomHeader [$index] [1] ) ) ); } if (! $this->sign_key_file) { $result .= $this->HeaderLine ( 'MIME-Version', '1.0' ); $result .= $this->GetMailMIME (); } return $result; } /** * Returns the message MIME. * @access public * @return string */ public function GetMailMIME() { $result = ''; switch ($this->message_type) { case 'plain' : $result .= $this->HeaderLine ( 'Content-Transfer-Encoding', $this->Encoding ); $result .= sprintf ( "Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet ); break; case 'attachments' : case 'alt_attachments' : if ($this->InlineImageExists ()) { $result .= sprintf ( "Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary [1], $this->LE ); } else { $result .= $this->HeaderLine ( 'Content-Type', 'multipart/mixed;' ); $result .= $this->TextLine ( "\tboundary=\"" . $this->boundary [1] . '"' ); } break; case 'alt' : $result .= $this->HeaderLine ( 'Content-Type', 'multipart/alternative;' ); $result .= $this->TextLine ( "\tboundary=\"" . $this->boundary [1] . '"' ); break; } if ($this->Mailer != 'mail') { $result .= $this->LE . $this->LE; } return $result; } /** * Assembles the message body. Returns an empty string on failure. * @access public * @return string The assembled message body */ public function CreateBody() { $body = ''; if ($this->sign_key_file) { $body .= $this->GetMailMIME (); } $this->SetWordWrap (); switch ($this->message_type) { case 'alt' : $body .= $this->GetBoundary ( $this->boundary [1], '', 'text/plain', '' ); $body .= $this->EncodeString ( $this->AltBody, $this->Encoding ); $body .= $this->LE . $this->LE; $body .= $this->GetBoundary ( $this->boundary [1], '', 'text/html', '' ); $body .= $this->EncodeString ( $this->Body, $this->Encoding ); $body .= $this->LE . $this->LE; $body .= $this->EndBoundary ( $this->boundary [1] ); break; case 'plain' : $body .= $this->EncodeString ( $this->Body, $this->Encoding ); break; case 'attachments' : $body .= $this->GetBoundary ( $this->boundary [1], '', '', '' ); $body .= $this->EncodeString ( $this->Body, $this->Encoding ); $body .= $this->LE; $body .= $this->AttachAll (); break; case 'alt_attachments' : $body .= sprintf ( "--%s%s", $this->boundary [1], $this->LE ); $body .= sprintf ( "Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary [2], $this->LE . $this->LE ); $body .= $this->GetBoundary ( $this->boundary [2], '', 'text/plain', '' ) . $this->LE; // Create text body $body .= $this->EncodeString ( $this->AltBody, $this->Encoding ); $body .= $this->LE . $this->LE; $body .= $this->GetBoundary ( $this->boundary [2], '', 'text/html', '' ) . $this->LE; // Create the HTML body $body .= $this->EncodeString ( $this->Body, $this->Encoding ); $body .= $this->LE . $this->LE; $body .= $this->EndBoundary ( $this->boundary [2] ); $body .= $this->AttachAll (); break; } if ($this->IsError ()) { $body = ''; } elseif ($this->sign_key_file) { try { $file = tempnam ( '', 'mail' ); file_put_contents ( $file, $body ); //TODO check this worked $signed = tempnam ( "", "signed" ); if (@openssl_pkcs7_sign ( $file, $signed, "file://" . $this->sign_cert_file, array ("file://" . $this->sign_key_file, $this->sign_key_pass ), NULL )) { @unlink ( $file ); @unlink ( $signed ); $body = file_get_contents ( $signed ); } else { @unlink ( $file ); @unlink ( $signed ); throw new phpmailerException ( $this->Lang ( "signing" ) . openssl_error_string () ); } } catch ( phpmailerException $e ) { $body = ''; if ($this->exceptions) { throw $e; } } } return $body; } /** * Returns the start of a message boundary. * @access private */ private function GetBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; if ($charSet == '') { $charSet = $this->CharSet; } if ($contentType == '') { $contentType = $this->ContentType; } if ($encoding == '') { $encoding = $this->Encoding; } $result .= $this->TextLine ( '--' . $boundary ); $result .= sprintf ( "Content-Type: %s; charset = \"%s\"", $contentType, $charSet ); $result .= $this->LE; $result .= $this->HeaderLine ( 'Content-Transfer-Encoding', $encoding ); $result .= $this->LE; return $result; } /** * Returns the end of a message boundary. * @access private */ private function EndBoundary($boundary) { return $this->LE . '--' . $boundary . '--' . $this->LE; } /** * Sets the message type. * @access private * @return void */ private function SetMessageType() { if (count ( $this->attachment ) < 1 && strlen ( $this->AltBody ) < 1) { $this->message_type = 'plain'; } else { if (count ( $this->attachment ) > 0) { $this->message_type = 'attachments'; } if (strlen ( $this->AltBody ) > 0 && count ( $this->attachment ) < 1) { $this->message_type = 'alt'; } if (strlen ( $this->AltBody ) > 0 && count ( $this->attachment ) > 0) { $this->message_type = 'alt_attachments'; } } } /** * Returns a formatted header line. * @access public * @return string */ public function HeaderLine($name, $value) { return $name . ': ' . $value . $this->LE; } /** * Returns a formatted mail line. * @access public * @return string */ public function TextLine($value) { return $value . $this->LE; } ///////////////////////////////////////////////// // CLASS METHODS, ATTACHMENTS ///////////////////////////////////////////////// /** * Adds an attachment from a path on the filesystem. * Returns false if the file could not be found * or accessed. * @param string $path Path to the attachment. * @param string $name Overrides the attachment name. * @param string $encoding File encoding (see $Encoding). * @param string $type File extension (MIME) type. * @return bool */ public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { try { if (! @is_file ( $path )) { throw new phpmailerException ( $this->Lang ( 'file_access' ) . $path, self::STOP_CONTINUE ); } $filename = basename ( $path ); if ($name == '') { $name = $filename; } $this->attachment [] = array (0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, // isStringAttachment 6 => 'attachment', 7 => 0 ); } catch ( phpmailerException $e ) { $this->SetError ( $e->getMessage () ); if ($this->exceptions) { throw $e; } echo $e->getMessage () . "\n"; if ($e->getCode () == self::STOP_CRITICAL) { return false; } } return true; } /** * Return the current array of attachments * @return array */ public function GetAttachments() { return $this->attachment; } /** * Attaches all fs, string, and binary attachments to the message. * Returns an empty string on failure. * @access private * @return string */ private function AttachAll() { // Return text of body $mime = array (); $cidUniq = array (); $incl = array (); // Add all attachments foreach ( $this->attachment as $attachment ) { // Check for string attachment $bString = $attachment [5]; if ($bString) { $string = $attachment [0]; } else { $path = $attachment [0]; } if (in_array ( $attachment [0], $incl )) { continue; } $filename = $attachment [1]; $name = $attachment [2]; $encoding = $attachment [3]; $type = $attachment [4]; $disposition = $attachment [6]; $cid = $attachment [7]; $incl [] = $attachment [0]; if ($disposition == 'inline' && isset ( $cidUniq [$cid] )) { continue; } $cidUniq [$cid] = true; $mime [] = sprintf ( "--%s%s", $this->boundary [1], $this->LE ); $mime [] = sprintf ( "Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader ( $this->SecureHeader ( $name ) ), $this->LE ); $mime [] = sprintf ( "Content-Transfer-Encoding: %s%s", $encoding, $this->LE ); if ($disposition == 'inline') { $mime [] = sprintf ( "Content-ID: <%s>%s", $cid, $this->LE ); } $mime [] = sprintf ( "Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader ( $this->SecureHeader ( $name ) ), $this->LE . $this->LE ); // Encode as string attachment if ($bString) { $mime [] = $this->EncodeString ( $string, $encoding ); if ($this->IsError ()) { return ''; } $mime [] = $this->LE . $this->LE; } else { $mime [] = $this->EncodeFile ( $path, $encoding ); if ($this->IsError ()) { return ''; } $mime [] = $this->LE . $this->LE; } } $mime [] = sprintf ( "--%s--%s", $this->boundary [1], $this->LE ); return join ( '', $mime ); } /** * Encodes attachment in requested format. * Returns an empty string on failure. * @param string $path The full path to the file * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' * @see EncodeFile() * @access private * @return string */ private function EncodeFile($path, $encoding = 'base64') { try { if (! is_readable ( $path )) { throw new phpmailerException ( $this->Lang ( 'file_open' ) . $path, self::STOP_CONTINUE ); } if (function_exists ( 'get_magic_quotes' )) { function get_magic_quotes() { return false; } } if (PHP_VERSION < 6) { $magic_quotes = get_magic_quotes_runtime (); set_magic_quotes_runtime ( 0 ); } $file_buffer = file_get_contents ( $path ); $file_buffer = $this->EncodeString ( $file_buffer, $encoding ); if (PHP_VERSION < 6) { set_magic_quotes_runtime ( $magic_quotes ); } return $file_buffer; } catch ( Exception $e ) { $this->SetError ( $e->getMessage () ); return ''; } } /** * Encodes string to requested format. * Returns an empty string on failure. * @param string $str The text to encode * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' * @access public * @return string */ public function EncodeString($str, $encoding = 'base64') { $encoded = ''; switch (strtolower ( $encoding )) { case 'base64' : $encoded = chunk_split ( base64_encode ( $str ), 76, $this->LE ); break; case '7bit' : case '8bit' : $encoded = $this->FixEOL ( $str ); //Make sure it ends with a line break if (substr ( $encoded, - (strlen ( $this->LE )) ) != $this->LE) $encoded .= $this->LE; break; case 'binary' : $encoded = $str; break; case 'quoted-printable' : $encoded = $this->EncodeQP ( $str ); break; default : $this->SetError ( $this->Lang ( 'encoding' ) . $encoding ); break; } return $encoded; } /** * Encode a header string to best (shortest) of Q, B, quoted or none. * @access public * @return string */ public function EncodeHeader($str, $position = 'text') { $x = 0; switch (strtolower ( $position )) { case 'phrase' : if (! preg_match ( '/[\200-\377]/', $str )) { // Can't use addslashes as we don't know what value has magic_quotes_sybase $encoded = addcslashes ( $str, "\0..\37\177\\\"" ); if (($str == $encoded) && ! preg_match ( '/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str )) { return ($encoded); } else { return ("\"$encoded\""); } } $x = preg_match_all ( '/[^\040\041\043-\133\135-\176]/', $str, $matches ); break; case 'comment' : $x = preg_match_all ( '/[()"]/', $str, $matches ); // Fall-through case 'text' : default : $x += preg_match_all ( '/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches ); break; } if ($x == 0) { return ($str); } $maxlen = 75 - 7 - strlen ( $this->CharSet ); // Try to select the encoding which should produce the shortest output if (strlen ( $str ) / 3 < $x) { $encoding = 'B'; if (function_exists ( 'mb_strlen' ) && $this->HasMultiBytes ( $str )) { // Use a custom function which correctly encodes and wraps long // multibyte strings without breaking lines within a character $encoded = $this->Base64EncodeWrapMB ( $str ); } else { $encoded = base64_encode ( $str ); $maxlen -= $maxlen % 4; $encoded = trim ( chunk_split ( $encoded, $maxlen, "\n" ) ); } } else { $encoding = 'Q'; $encoded = $this->EncodeQ ( $str, $position ); $encoded = $this->WrapText ( $encoded, $maxlen, true ); $encoded = str_replace ( '=' . $this->LE, "\n", trim ( $encoded ) ); } $encoded = preg_replace ( '/^(.*)$/m', " =?" . $this->CharSet . "?$encoding?\\1?=", $encoded ); $encoded = trim ( str_replace ( "\n", $this->LE, $encoded ) ); return $encoded; } /** * Checks if a string contains multibyte characters. * @access public * @param string $str multi-byte text to wrap encode * @return bool */ public function HasMultiBytes($str) { if (function_exists ( 'mb_strlen' )) { return (strlen ( $str ) > mb_strlen ( $str, $this->CharSet )); } else { // Assume no multibytes (we can't handle without mbstring functions anyway) return false; } } /** * Correctly encodes and wraps long multibyte strings for mail headers * without breaking lines within a character. * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php * @access public * @param string $str multi-byte text to wrap encode * @return string */ public function Base64EncodeWrapMB($str) { $start = "=?" . $this->CharSet . "?B?"; $end = "?="; $encoded = ""; $mb_length = mb_strlen ( $str, $this->CharSet ); // Each line must have length <= 75, including $start and $end $length = 75 - strlen ( $start ) - strlen ( $end ); // Average multi-byte ratio $ratio = $mb_length / strlen ( $str ); // Base64 has a 4:3 ratio $offset = $avgLength = floor ( $length * $ratio * .75 ); for($i = 0; $i < $mb_length; $i += $offset) { $lookBack = 0; do { $offset = $avgLength - $lookBack; $chunk = mb_substr ( $str, $i, $offset, $this->CharSet ); $chunk = base64_encode ( $chunk ); $lookBack ++; } while ( strlen ( $chunk ) > $length ); $encoded .= $chunk . $this->LE; } // Chomp the last linefeed $encoded = substr ( $encoded, 0, - strlen ( $this->LE ) ); return $encoded; } /** * Encode string to quoted-printable. * Only uses standard PHP, slow, but will always work * @access public * @param string $string the text to encode * @param integer $line_max Number of chars allowed on a line before wrapping * @return string */ public function EncodeQPphp($input = '', $line_max = 76, $space_conv = false) { $hex = array ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ); $lines = preg_split ( '/(?:\r\n|\r|\n)/', $input ); $eol = "\r\n"; $escape = '='; $output = ''; while ( list ( , $line ) = each ( $lines ) ) { $linlen = strlen ( $line ); $newline = ''; for($i = 0; $i < $linlen; $i ++) { $c = substr ( $line, $i, 1 ); $dec = ord ( $c ); if (($i == 0) && ($dec == 46)) { // convert first point in the line into =2E $c = '=2E'; } if ($dec == 32) { if ($i == ($linlen - 1)) { // convert space at eol only $c = '=20'; } else if ($space_conv) { $c = '=20'; } } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required $h2 = floor ( $dec / 16 ); $h1 = floor ( $dec % 16 ); $c = $escape . $hex [$h2] . $hex [$h1]; } if ((strlen ( $newline ) + strlen ( $c )) >= $line_max) { // CRLF is not counted $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay $newline = ''; // check if newline first character will be point or not if ($dec == 46) { $c = '=2E'; } } $newline .= $c; } // end of for $output .= $newline . $eol; } // end of while return $output; } /** * Encode string to RFC2045 (6.7) quoted-printable format * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version * Also results in same content as you started with after decoding * @see EncodeQPphp() * @access public * @param string $string the text to encode * @param integer $line_max Number of chars allowed on a line before wrapping * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function * @return string * @author Marcus Bointon */ public function EncodeQP($string, $line_max = 76, $space_conv = false) { if (function_exists ( 'quoted_printable_encode' )) { //Use native function if it's available (>= PHP5.3) return quoted_printable_encode ( $string ); } $filters = stream_get_filters (); if (! in_array ( 'convert.*', $filters )) { //Got convert stream filter? return $this->EncodeQPphp ( $string, $line_max, $space_conv ); //Fall back to old implementation } $fp = fopen ( 'php://temp/', 'r+' ); $string = preg_replace ( '/\r\n?/', $this->LE, $string ); //Normalise line breaks $params = array ('line-length' => $line_max, 'line-break-chars' => $this->LE ); $s = stream_filter_append ( $fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params ); fputs ( $fp, $string ); rewind ( $fp ); $out = stream_get_contents ( $fp ); stream_filter_remove ( $s ); $out = preg_replace ( '/^\./m', '=2E', $out ); //Encode . if it is first char on a line, workaround for bug in Exchange fclose ( $fp ); return $out; } /** * Encode string to q encoding. * @link http://tools.ietf.org/html/rfc2047 * @param string $str the text to encode * @param string $position Where the text is going to be used, see the RFC for what that means * @access public * @return string */ public function EncodeQ($str, $position = 'text') { // There should not be any EOL in the string $encoded = preg_replace ( '/[\r\n]*/', '', $str ); switch (strtolower ( $position )) { case 'phrase' : $encoded = preg_replace ( "/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded ); break; case 'comment' : $encoded = preg_replace ( "/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded ); case 'text' : default : // Replace every high ascii, control =, ? and _ characters //TODO using /e (equivalent to eval()) is probably not a good idea $encoded = preg_replace ( '/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', "'='.sprintf('%02X', ord('\\1'))", $encoded ); break; } // Replace every spaces to _ (more readable than =20) $encoded = str_replace ( ' ', '_', $encoded ); return $encoded; } /** * Adds a string or binary attachment (non-filesystem) to the list. * This method can be used to attach ascii or binary data, * such as a BLOB record from a database. * @param string $string String attachment data. * @param string $filename Name of the attachment. * @param string $encoding File encoding (see $Encoding). * @param string $type File extension (MIME) type. * @return void */ public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { // Append to $attachment array $this->attachment [] = array (0 => $string, 1 => $filename, 2 => basename ( $filename ), 3 => $encoding, 4 => $type, 5 => true, // isStringAttachment 6 => 'attachment', 7 => 0 ); } /** * Adds an embedded attachment. This can include images, sounds, and * just about any other document. Make sure to set the $type to an * image type. For JPEG images use "image/jpeg" and for GIF images * use "image/gif". * @param string $path Path to the attachment. * @param string $cid Content ID of the attachment. Use this to identify * the Id for accessing the image in an HTML form. * @param string $name Overrides the attachment name. * @param string $encoding File encoding (see $Encoding). * @param string $type File extension (MIME) type. * @return bool */ public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { if (! @is_file ( $path )) { $this->SetError ( $this->Lang ( 'file_access' ) . $path ); return false; } $filename = basename ( $path ); if ($name == '') { $name = $filename; } // Append to $attachment array $this->attachment [] = array (0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, // isStringAttachment 6 => 'inline', 7 => $cid ); return true; } /** * Returns true if an inline attachment is present. * @access public * @return bool */ public function InlineImageExists() { foreach ( $this->attachment as $attachment ) { if ($attachment [6] == 'inline') { return true; } } return false; } ///////////////////////////////////////////////// // CLASS METHODS, MESSAGE RESET ///////////////////////////////////////////////// /** * Clears all recipients assigned in the TO array. Returns void. * @return void */ public function ClearAddresses() { foreach ( $this->to as $to ) { unset ( $this->all_recipients [strtolower ( $to [0] )] ); } $this->to = array (); } /** * Clears all recipients assigned in the CC array. Returns void. * @return void */ public function ClearCCs() { foreach ( $this->cc as $cc ) { unset ( $this->all_recipients [strtolower ( $cc [0] )] ); } $this->cc = array (); } /** * Clears all recipients assigned in the BCC array. Returns void. * @return void */ public function ClearBCCs() { foreach ( $this->bcc as $bcc ) { unset ( $this->all_recipients [strtolower ( $bcc [0] )] ); } $this->bcc = array (); } /** * Clears all recipients assigned in the ReplyTo array. Returns void. * @return void */ public function ClearReplyTos() { $this->ReplyTo = array (); } /** * Clears all recipients assigned in the TO, CC and BCC * array. Returns void. * @return void */ public function ClearAllRecipients() { $this->to = array (); $this->cc = array (); $this->bcc = array (); $this->all_recipients = array (); } /** * Clears all previously set filesystem, string, and binary * attachments. Returns void. * @return void */ public function ClearAttachments() { $this->attachment = array (); } /** * Clears all custom headers. Returns void. * @return void */ public function ClearCustomHeaders() { $this->CustomHeader = array (); } ///////////////////////////////////////////////// // CLASS METHODS, MISCELLANEOUS ///////////////////////////////////////////////// /** * Adds the error message to the error container. * @access protected * @return void */ protected function SetError($msg) { $this->error_count ++; if ($this->Mailer == 'smtp' and ! is_null ( $this->smtp )) { $lasterror = $this->smtp->getError (); if (! empty ( $lasterror ) and array_key_exists ( 'smtp_msg', $lasterror )) { $msg .= '<p>' . $this->Lang ( 'smtp_error' ) . $lasterror ['smtp_msg'] . "</p>\n"; } } $this->ErrorInfo = $msg; } /** * Returns the proper RFC 822 formatted date. * @access public * @return string * @static */ public static function RFCDate() { $tz = date ( 'Z' ); $tzs = ($tz < 0) ? '-' : '+'; $tz = abs ( $tz ); $tz = ( int ) ($tz / 3600) * 100 + ($tz % 3600) / 60; $result = sprintf ( "%s %s%04d", date ( 'D, j M Y H:i:s' ), $tzs, $tz ); return $result; } /** * Returns the server hostname or 'localhost.localdomain' if unknown. * @access private * @return string */ private function ServerHostname() { if (! empty ( $this->Hostname )) { $result = $this->Hostname; } elseif (isset ( $_SERVER ['SERVER_NAME'] )) { $result = $_SERVER ['SERVER_NAME']; } else { $result = 'localhost.localdomain'; } return $result; } /** * Returns a message in the appropriate language. * @access private * @return string */ private function Lang($key) { if (count ( $this->language ) < 1) { $this->SetLanguage ( 'en' ); // set the default language } if (isset ( $this->language [$key] )) { return $this->language [$key]; } else { return 'Language string failed to load: ' . $key; } } /** * Returns true if an error occurred. * @access public * @return bool */ public function IsError() { return ($this->error_count > 0); } /** * Changes every end of line from CR or LF to CRLF. * @access private * @return string */ private function FixEOL($str) { $str = str_replace ( "\r\n", "\n", $str ); $str = str_replace ( "\r", "\n", $str ); $str = str_replace ( "\n", $this->LE, $str ); return $str; } /** * Adds a custom header. * @access public * @return void */ public function AddCustomHeader($custom_header) { $this->CustomHeader [] = explode ( ':', $custom_header, 2 ); } /** * Evaluates the message and returns modifications for inline images and backgrounds * @access public * @return $message */ public function MsgHTML($message, $basedir = '') { preg_match_all ( "/(src|background)=\"(.*)\"/Ui", $message, $images ); if (isset ( $images [2] )) { foreach ( $images [2] as $i => $url ) { // do not change urls for absolute images (thanks to corvuscorax) if (! preg_match ( '#^[A-z]+://#', $url )) { $filename = basename ( $url ); $directory = dirname ( $url ); ($directory == '.') ? $directory = '' : ''; $cid = 'cid:' . md5 ( $filename ); $ext = pathinfo ( $filename, PATHINFO_EXTENSION ); $mimeType = self::_mime_types ( $ext ); if (strlen ( $basedir ) > 1 && substr ( $basedir, - 1 ) != '/') { $basedir .= '/'; } if (strlen ( $directory ) > 1 && substr ( $directory, - 1 ) != '/') { $directory .= '/'; } if ($this->AddEmbeddedImage ( $basedir . $directory . $filename, md5 ( $filename ), $filename, 'base64', $mimeType )) { $message = preg_replace ( "/" . $images [1] [$i] . "=\"" . preg_quote ( $url, '/' ) . "\"/Ui", $images [1] [$i] . "=\"" . $cid . "\"", $message ); } } } } $this->IsHTML ( true ); $this->Body = $message; $textMsg = trim ( strip_tags ( preg_replace ( '/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message ) ) ); if (! empty ( $textMsg ) && empty ( $this->AltBody )) { $this->AltBody = html_entity_decode ( $textMsg ); } if (empty ( $this->AltBody )) { $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; } } /** * Gets the MIME type of the embedded or inline image * @param string File extension * @access public * @return string MIME type of ext * @static */ public static function _mime_types($ext = '') { $mimes = array ('hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/macbinary', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'so' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'rv' => 'video/vnd.rn-realvideo', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'txt' => 'text/plain', 'text' => 'text/plain', 'log' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'doc' => 'application/msword', 'word' => 'application/msword', 'xl' => 'application/excel', 'eml' => 'message/rfc822' ); return (! isset ( $mimes [strtolower ( $ext )] )) ? 'application/octet-stream' : $mimes [strtolower ( $ext )]; } /** * Set (or reset) Class Objects (variables) * * Usage Example: * $page->set('X-Priority', '3'); * * @access public * @param string $name Parameter Name * @param mixed $value Parameter Value * NOTE: will not work with arrays, there are no arrays to set/reset * @todo Should this not be using __set() magic function? */ public function set($name, $value = '') { try { if (isset ( $this->$name )) { $this->$name = $value; } else { throw new phpmailerException ( $this->Lang ( 'variable_set' ) . $name, self::STOP_CRITICAL ); } } catch ( Exception $e ) { $this->SetError ( $e->getMessage () ); if ($e->getCode () == self::STOP_CRITICAL) { return false; } } return true; } /** * Strips newlines to prevent header injection. * @access public * @param string $str String * @return string */ public function SecureHeader($str) { $str = str_replace ( "\r", '', $str ); $str = str_replace ( "\n", '', $str ); return trim ( $str ); } /** * Set the private key file and password to sign the message. * * @access public * @param string $key_filename Parameter File Name * @param string $key_pass Password for private key */ public function Sign($cert_filename, $key_filename, $key_pass) { $this->sign_cert_file = $cert_filename; $this->sign_key_file = $key_filename; $this->sign_key_pass = $key_pass; } /** * Set the private key file and password to sign the message. * * @access public * @param string $key_filename Parameter File Name * @param string $key_pass Password for private key */ public function DKIM_QP($txt) { $tmp = ""; $line = ""; for($i = 0; $i < strlen ( $txt ); $i ++) { $ord = ord ( $txt [$i] ); if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { $line .= $txt [$i]; } else { $line .= "=" . sprintf ( "%02X", $ord ); } } return $line; } /** * Generate DKIM signature * * @access public * @param string $s Header */ public function DKIM_Sign($s) { $privKeyStr = file_get_contents ( $this->DKIM_private ); if ($this->DKIM_passphrase != '') { $privKey = openssl_pkey_get_private ( $privKeyStr, $this->DKIM_passphrase ); } else { $privKey = $privKeyStr; } if (openssl_sign ( $s, $signature, $privKey )) { return base64_encode ( $signature ); } } /** * Generate DKIM Canonicalization Header * * @access public * @param string $s Header */ public function DKIM_HeaderC($s) { $s = preg_replace ( "/\r\n\s+/", " ", $s ); $lines = explode ( "\r\n", $s ); foreach ( $lines as $key => $line ) { list ( $heading, $value ) = explode ( ":", $line, 2 ); $heading = strtolower ( $heading ); $value = preg_replace ( "/\s+/", " ", $value ); // Compress useless spaces $lines [$key] = $heading . ":" . trim ( $value ); // Don't forget to remove WSP around the value } $s = implode ( "\r\n", $lines ); return $s; } /** * Generate DKIM Canonicalization Body * * @access public * @param string $body Message Body */ public function DKIM_BodyC($body) { if ($body == '') return "\r\n"; // stabilize line endings $body = str_replace ( "\r\n", "\n", $body ); $body = str_replace ( "\n", "\r\n", $body ); // END stabilize line endings while ( substr ( $body, strlen ( $body ) - 4, 4 ) == "\r\n\r\n" ) { $body = substr ( $body, 0, strlen ( $body ) - 2 ); } return $body; } /** * Create the DKIM header, body, as new header * * @access public * @param string $headers_line Header lines * @param string $subject Subject * @param string $body Body */ public function DKIM_Add($headers_line, $subject, $body) { $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body $DKIMquery = 'dns/txt'; // Query method $DKIMtime = time (); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) $subject_header = "Subject: $subject"; $headers = explode ( "\r\n", $headers_line ); foreach ( $headers as $header ) { if (strpos ( $header, 'From:' ) === 0) { $from_header = $header; } elseif (strpos ( $header, 'To:' ) === 0) { $to_header = $header; } } $from = str_replace ( '|', '=7C', $this->DKIM_QP ( $from_header ) ); $to = str_replace ( '|', '=7C', $this->DKIM_QP ( $to_header ) ); $subject = str_replace ( '|', '=7C', $this->DKIM_QP ( $subject_header ) ); // Copied header fields (dkim-quoted-printable $body = $this->DKIM_BodyC ( $body ); $DKIMlen = strlen ( $body ); // Length of body $DKIMb64 = base64_encode ( pack ( "H*", sha1 ( $body ) ) ); // Base64 of packed binary SHA-1 hash of body $ident = ($this->DKIM_identity == '') ? '' : " i=" . $this->DKIM_identity . ";"; $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n" . "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n" . "\th=From:To:Subject;\r\n" . "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n" . "\tz=$from\r\n" . "\t|$to\r\n" . "\t|$subject;\r\n" . "\tbh=" . $DKIMb64 . ";\r\n" . "\tb="; $toSign = $this->DKIM_HeaderC ( $from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs ); $signed = $this->DKIM_Sign ( $toSign ); return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n" . $dkimhdrs . $signed . "\r\n"; } protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) { if (! empty ( $this->action_function ) && function_exists ( $this->action_function )) { $params = array ($isSent, $to, $cc, $bcc, $subject, $body ); call_user_func_array ( $this->action_function, $params ); } } } class phpmailerException extends Exception { public function errorMessage() { $errorMsg = '<strong>' . $this->getMessage () . "</strong><br />\n"; return $errorMsg; } } ?>
12ik
trunk/core/PHPMailer/class.phpmailer.php
PHP
oos
73,301
<?php /*~ class.pop3.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | | Version: 5.1 | | Contact: via sourceforge.net support pages (also www.codeworxtech.com) | | Info: http://phpmailer.sourceforge.net | | Support: http://sourceforge.net/projects/phpmailer/ | | ------------------------------------------------------------------------- | | Admin: Andy Prevost (project admininistrator) | | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | | Founder: Brent R. Matzelle (original founder) | | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | | License: Distributed under the Lesser General Public License (LGPL) | | http://www.gnu.org/copyleft/lesser.html | | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | | ------------------------------------------------------------------------- | | We offer a number of paid services (www.codeworxtech.com): | | - Web Hosting on highly optimized fast and secure servers | | - Technology Consulting | | - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' */ /** * PHPMailer - PHP POP Before SMTP Authentication Class * NOTE: Designed for use with PHP version 5 and up * @package PHPMailer * @author Andy Prevost * @author Marcus Bointon * @copyright 2004 - 2009 Andy Prevost * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL) * @version $Id: class.pop3.php 208 2011-10-21 17:24:48Z wanglijun $ */ /** * POP Before SMTP Authentication Class * Version 5.0.0 * * Author: Richard Davey (rich@corephp.co.uk) * Modifications: Andy Prevost * License: LGPL, see PHPMailer License * * Specifically for PHPMailer to allow POP before SMTP authentication. * Does not yet work with APOP - if you have an APOP account, contact Richard Davey * and we can test changes to this script. * * This class is based on the structure of the SMTP class originally authored by Chris Ryan * * This class is rfc 1939 compliant and implements all the commands * required for POP3 connection, authentication and disconnection. * * @package PHPMailer * @author Richard Davey */ class POP3 { /** * Default POP3 port * @var int */ public $POP3_PORT = 110; /** * Default Timeout * @var int */ public $POP3_TIMEOUT = 30; /** * POP3 Carriage Return + Line Feed * @var string */ public $CRLF = "\r\n"; /** * Displaying Debug warnings? (0 = now, 1+ = yes) * @var int */ public $do_debug = 2; /** * POP3 Mail Server * @var string */ public $host; /** * POP3 Port * @var int */ public $port; /** * POP3 Timeout Value * @var int */ public $tval; /** * POP3 Username * @var string */ public $username; /** * POP3 Password * @var string */ public $password; ///////////////////////////////////////////////// // PROPERTIES, PRIVATE AND PROTECTED ///////////////////////////////////////////////// private $pop_conn; private $connected; private $error; // Error log array /** * Constructor, sets the initial values * @access public * @return POP3 */ public function __construct() { $this->pop_conn = 0; $this->connected = false; $this->error = null; } /** * Combination of public events - connect, login, disconnect * @access public * @param string $host * @param integer $port * @param integer $tval * @param string $username * @param string $password */ public function Authorise($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { $this->host = $host; // If no port value is passed, retrieve it if ($port == false) { $this->port = $this->POP3_PORT; } else { $this->port = $port; } // If no port value is passed, retrieve it if ($tval == false) { $this->tval = $this->POP3_TIMEOUT; } else { $this->tval = $tval; } $this->do_debug = $debug_level; $this->username = $username; $this->password = $password; // Refresh the error log $this->error = null; // Connect $result = $this->Connect ( $this->host, $this->port, $this->tval ); if ($result) { $login_result = $this->Login ( $this->username, $this->password ); if ($login_result) { $this->Disconnect (); return true; } } // We need to disconnect regardless if the login succeeded $this->Disconnect (); return false; } /** * Connect to the POP3 server * @access public * @param string $host * @param integer $port * @param integer $tval * @return boolean */ public function Connect($host, $port = false, $tval = 30) { // Are we already connected? if ($this->connected) { return true; } /* On Windows this will raise a PHP Warning error if the hostname doesn't exist. Rather than supress it with @fsockopen, let's capture it cleanly instead */ set_error_handler ( array (&$this, 'catchWarning' ) ); // Connect to the POP3 server $this->pop_conn = fsockopen ( $host, // POP3 Host $port, // Port # $errno, // Error Number $errstr, // Error Message $tval ); // Timeout (seconds) // Restore the error handler restore_error_handler (); // Does the Error Log now contain anything? if ($this->error && $this->do_debug >= 1) { $this->displayErrors (); } // Did we connect? if ($this->pop_conn == false) { // It would appear not... $this->error = array ('error' => "Failed to connect to server $host on port $port", 'errno' => $errno, 'errstr' => $errstr ); if ($this->do_debug >= 1) { $this->displayErrors (); } return false; } // Increase the stream time-out // Check for PHP 4.3.0 or later if (version_compare ( phpversion (), '5.0.0', 'ge' )) { stream_set_timeout ( $this->pop_conn, $tval, 0 ); } else { // Does not work on Windows if (substr ( PHP_OS, 0, 3 ) !== 'WIN') { socket_set_timeout ( $this->pop_conn, $tval, 0 ); } } // Get the POP3 server response $pop3_response = $this->getResponse (); // Check for the +OK if ($this->checkResponse ( $pop3_response )) { // The connection is established and the POP3 server is talking $this->connected = true; return true; } } /** * Login to the POP3 server (does not support APOP yet) * @access public * @param string $username * @param string $password * @return boolean */ public function Login($username = '', $password = '') { if ($this->connected == false) { $this->error = 'Not connected to POP3 server'; if ($this->do_debug >= 1) { $this->displayErrors (); } } if (empty ( $username )) { $username = $this->username; } if (empty ( $password )) { $password = $this->password; } $pop_username = "USER $username" . $this->CRLF; $pop_password = "PASS $password" . $this->CRLF; // Send the Username $this->sendString ( $pop_username ); $pop3_response = $this->getResponse (); if ($this->checkResponse ( $pop3_response )) { // Send the Password $this->sendString ( $pop_password ); $pop3_response = $this->getResponse (); if ($this->checkResponse ( $pop3_response )) { return true; } else { return false; } } else { return false; } } /** * Disconnect from the POP3 server * @access public */ public function Disconnect() { $this->sendString ( 'QUIT' ); fclose ( $this->pop_conn ); } ///////////////////////////////////////////////// // Private Methods ///////////////////////////////////////////////// /** * Get the socket response back. * $size is the maximum number of bytes to retrieve * @access private * @param integer $size * @return string */ private function getResponse($size = 128) { $pop3_response = fgets ( $this->pop_conn, $size ); return $pop3_response; } /** * Send a string down the open socket connection to the POP3 server * @access private * @param string $string * @return integer */ private function sendString($string) { $bytes_sent = fwrite ( $this->pop_conn, $string, strlen ( $string ) ); return $bytes_sent; } /** * Checks the POP3 server response for +OK or -ERR * @access private * @param string $string * @return boolean */ private function checkResponse($string) { if (substr ( $string, 0, 3 ) !== '+OK') { $this->error = array ('error' => "Server reported an error: $string", 'errno' => 0, 'errstr' => '' ); if ($this->do_debug >= 1) { $this->displayErrors (); } return false; } else { return true; } } /** * If debug is enabled, display the error message array * @access private */ private function displayErrors() { echo '<pre>'; foreach ( $this->error as $single_error ) { print_r ( $single_error ); } echo '</pre>'; } /** * Takes over from PHP for the socket warning handler * @access private * @param integer $errno * @param string $errstr * @param string $errfile * @param integer $errline */ private function catchWarning($errno, $errstr, $errfile, $errline) { $this->error [] = array ('error' => "Connecting to the POP3 server raised a PHP warning: ", 'errno' => $errno, 'errstr' => $errstr ); } // End of class } ?>
12ik
trunk/core/PHPMailer/class.pop3.php
PHP
oos
10,572
<?php /*~ class.smtp.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | | Version: 5.1 | | Contact: via sourceforge.net support pages (also www.codeworxtech.com) | | Info: http://phpmailer.sourceforge.net | | Support: http://sourceforge.net/projects/phpmailer/ | | ------------------------------------------------------------------------- | | Admin: Andy Prevost (project admininistrator) | | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | | Founder: Brent R. Matzelle (original founder) | | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | | License: Distributed under the Lesser General Public License (LGPL) | | http://www.gnu.org/copyleft/lesser.html | | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | | ------------------------------------------------------------------------- | | We offer a number of paid services (www.codeworxtech.com): | | - Web Hosting on highly optimized fast and secure servers | | - Technology Consulting | | - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' */ /** * PHPMailer - PHP SMTP email transport class * NOTE: Designed for use with PHP version 5 and up * @package PHPMailer * @author Andy Prevost * @author Marcus Bointon * @copyright 2004 - 2008 Andy Prevost * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL) * @version $Id: class.smtp.php 208 2011-10-21 17:24:48Z wanglijun $ */ /** * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP * commands except TURN which will always return a not implemented * error. SMTP also provides some utility methods for sending mail * to an SMTP server. * original author: Chris Ryan */ class SMTP { /** * SMTP server port * @var int */ public $SMTP_PORT = 25; /** * SMTP reply line ending * @var string */ public $CRLF = "\r\n"; /** * Sets whether debugging is turned on * @var bool */ public $do_debug; // the level of debug to perform /** * Sets VERP use on/off (default is off) * @var bool */ public $do_verp = false; ///////////////////////////////////////////////// // PROPERTIES, PRIVATE AND PROTECTED ///////////////////////////////////////////////// private $smtp_conn; // the socket to the server private $error; // error if any on the last call private $helo_rply; // the reply the server sent to us for HELO /** * Initialize the class so that the data is in a known state. * @access public * @return void */ public function __construct() { $this->smtp_conn = 0; $this->error = null; $this->helo_rply = null; $this->do_debug = 0; } ///////////////////////////////////////////////// // CONNECTION FUNCTIONS ///////////////////////////////////////////////// /** * Connect to the server specified on the port specified. * If the port is not specified use the default SMTP_PORT. * If tval is specified then a connection will try and be * established with the server for that number of seconds. * If tval is not specified the default is 30 seconds to * try on the connection. * * SMTP CODE SUCCESS: 220 * SMTP CODE FAILURE: 421 * @access public * @return bool */ public function Connect($host, $port = 0, $tval = 30) { // set the error val to null so there is no confusion $this->error = null; // make sure we are __not__ connected if ($this->connected ()) { // already connected, generate error $this->error = array ("error" => "Already connected to a server" ); return false; } if (empty ( $port )) { $port = $this->SMTP_PORT; } // connect to the smtp server $this->smtp_conn = @fsockopen ( $host, // the host of the server $port, // the port to use $errno, // error number if any $errstr, // error message if any $tval ); // give up after ? secs // verify we connected properly if (empty ( $this->smtp_conn )) { $this->error = array ("error" => "Failed to connect to server", "errno" => $errno, "errstr" => $errstr ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />'; } return false; } // SMTP server can take longer to respond, give longer timeout for first read // Windows does not have support for this timeout function if (substr ( PHP_OS, 0, 3 ) != "WIN") socket_set_timeout ( $this->smtp_conn, $tval, 0 ); // get any announcement $announce = $this->get_lines (); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; } return true; } /** * Initiate a TLS communication with the server. * * SMTP CODE 220 Ready to start TLS * SMTP CODE 501 Syntax error (no parameters allowed) * SMTP CODE 454 TLS not available due to temporary reason * @access public * @return bool success */ public function StartTLS() { $this->error = null; # to avoid confusion if (! $this->connected ()) { $this->error = array ("error" => "Called StartTLS() without being connected" ); return false; } fputs ( $this->smtp_conn, "STARTTLS" . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 220) { $this->error = array ("error" => "STARTTLS not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } // Begin encrypted connection if (! stream_socket_enable_crypto ( $this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT )) { return false; } return true; } /** * Performs SMTP authentication. Must be run after running the * Hello() method. Returns true if successfully authenticated. * @access public * @return bool */ public function Authenticate($username, $password) { // Start authentication fputs ( $this->smtp_conn, "AUTH LOGIN" . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($code != 334) { $this->error = array ("error" => "AUTH not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } // Send encoded username fputs ( $this->smtp_conn, base64_encode ( $username ) . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($code != 334) { $this->error = array ("error" => "Username not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } // Send encoded password fputs ( $this->smtp_conn, base64_encode ( $password ) . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($code != 235) { $this->error = array ("error" => "Password not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } return true; } /** * Returns true if connected to a server otherwise false * @access public * @return bool */ public function Connected() { if (! empty ( $this->smtp_conn )) { $sock_status = socket_get_status ( $this->smtp_conn ); if ($sock_status ["eof"]) { // the socket is valid but we are not connected if ($this->do_debug >= 1) { echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; } $this->Close (); return false; } return true; // everything looks good } return false; } /** * Closes the socket and cleans up the state of the class. * It is not considered good to use this function without * first trying to use QUIT. * @access public * @return void */ public function Close() { $this->error = null; // so there is no confusion $this->helo_rply = null; if (! empty ( $this->smtp_conn )) { // close the connection and cleanup fclose ( $this->smtp_conn ); $this->smtp_conn = 0; } } ///////////////////////////////////////////////// // SMTP COMMANDS ///////////////////////////////////////////////// /** * Issues a data command and sends the msg_data to the server * finializing the mail transaction. $msg_data is the message * that is to be send with the headers. Each header needs to be * on a single line followed by a <CRLF> with the message headers * and the message body being seperated by and additional <CRLF>. * * Implements rfc 821: DATA <CRLF> * * SMTP CODE INTERMEDIATE: 354 * [data] * <CRLF>.<CRLF> * SMTP CODE SUCCESS: 250 * SMTP CODE FAILURE: 552,554,451,452 * SMTP CODE FAILURE: 451,554 * SMTP CODE ERROR : 500,501,503,421 * @access public * @return bool */ public function Data($msg_data) { $this->error = null; // so no confusion is caused if (! $this->connected ()) { $this->error = array ("error" => "Called Data() without being connected" ); return false; } fputs ( $this->smtp_conn, "DATA" . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 354) { $this->error = array ("error" => "DATA command not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } /* the server is ready to accept data! * according to rfc 821 we should not send more than 1000 * including the CRLF * characters on a single line so we will break the data up * into lines by \r and/or \n then if needed we will break * each of those into smaller lines to fit within the limit. * in addition we will be looking for lines that start with * a period '.' and append and additional period '.' to that * line. NOTE: this does not count towards limit. */ // normalize the line breaks so we know the explode works $msg_data = str_replace ( "\r\n", "\n", $msg_data ); $msg_data = str_replace ( "\r", "\n", $msg_data ); $lines = explode ( "\n", $msg_data ); /* we need to find a good way to determine is headers are * in the msg_data or if it is a straight msg body * currently I am assuming rfc 822 definitions of msg headers * and if the first field of the first line (':' sperated) * does not contain a space then it _should_ be a header * and we can process all lines before a blank "" line as * headers. */ $field = substr ( $lines [0], 0, strpos ( $lines [0], ":" ) ); $in_headers = false; if (! empty ( $field ) && ! strstr ( $field, " " )) { $in_headers = true; } $max_line_length = 998; // used below; set here for ease in change while ( list ( , $line ) = @each ( $lines ) ) { $lines_out = null; if ($line == "" && $in_headers) { $in_headers = false; } // ok we need to break this line up into several smaller lines while ( strlen ( $line ) > $max_line_length ) { $pos = strrpos ( substr ( $line, 0, $max_line_length ), " " ); // Patch to fix DOS attack if (! $pos) { $pos = $max_line_length - 1; $lines_out [] = substr ( $line, 0, $pos ); $line = substr ( $line, $pos ); } else { $lines_out [] = substr ( $line, 0, $pos ); $line = substr ( $line, $pos + 1 ); } /* if processing headers add a LWSP-char to the front of new line * rfc 822 on long msg headers */ if ($in_headers) { $line = "\t" . $line; } } $lines_out [] = $line; // send the lines to the server while ( list ( , $line_out ) = @each ( $lines_out ) ) { if (strlen ( $line_out ) > 0) { if (substr ( $line_out, 0, 1 ) == ".") { $line_out = "." . $line_out; } } fputs ( $this->smtp_conn, $line_out . $this->CRLF ); } } // message data has been sent fputs ( $this->smtp_conn, $this->CRLF . "." . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 250) { $this->error = array ("error" => "DATA not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } return true; } /** * Sends the HELO command to the smtp server. * This makes sure that we and the server are in * the same known state. * * Implements from rfc 821: HELO <SP> <domain> <CRLF> * * SMTP CODE SUCCESS: 250 * SMTP CODE ERROR : 500, 501, 504, 421 * @access public * @return bool */ public function Hello($host = '') { $this->error = null; // so no confusion is caused if (! $this->connected ()) { $this->error = array ("error" => "Called Hello() without being connected" ); return false; } // if hostname for HELO was not specified send default if (empty ( $host )) { // determine appropriate default to send to server $host = "localhost"; } // Send extended hello first (RFC 2821) if (! $this->SendHello ( "EHLO", $host )) { if (! $this->SendHello ( "HELO", $host )) { return false; } } return true; } /** * Sends a HELO/EHLO command. * @access private * @return bool */ private function SendHello($hello, $host) { fputs ( $this->smtp_conn, $hello . " " . $host . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; } if ($code != 250) { $this->error = array ("error" => $hello . " not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } $this->helo_rply = $rply; return true; } /** * Starts a mail transaction from the email address specified in * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more Recipient * commands may be called followed by a Data command. * * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF> * * SMTP CODE SUCCESS: 250 * SMTP CODE SUCCESS: 552,451,452 * SMTP CODE SUCCESS: 500,501,421 * @access public * @return bool */ public function Mail($from) { $this->error = null; // so no confusion is caused if (! $this->connected ()) { $this->error = array ("error" => "Called Mail() without being connected" ); return false; } $useVerp = ($this->do_verp ? "XVERP" : ""); fputs ( $this->smtp_conn, "MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 250) { $this->error = array ("error" => "MAIL not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } return true; } /** * Sends the quit command to the server and then closes the socket * if there is no error or the $close_on_error argument is true. * * Implements from rfc 821: QUIT <CRLF> * * SMTP CODE SUCCESS: 221 * SMTP CODE ERROR : 500 * @access public * @return bool */ public function Quit($close_on_error = true) { $this->error = null; // so there is no confusion if (! $this->connected ()) { $this->error = array ("error" => "Called Quit() without being connected" ); return false; } // send the quit command to the server fputs ( $this->smtp_conn, "quit" . $this->CRLF ); // get any good-bye messages $byemsg = $this->get_lines (); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; } $rval = true; $e = null; $code = substr ( $byemsg, 0, 3 ); if ($code != 221) { // use e as a tmp var cause Close will overwrite $this->error $e = array ("error" => "SMTP server rejected quit command", "smtp_code" => $code, "smtp_rply" => substr ( $byemsg, 4 ) ); $rval = false; if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $e ["error"] . ": " . $byemsg . $this->CRLF . '<br />'; } } if (empty ( $e ) || $close_on_error) { $this->Close (); } return $rval; } /** * Sends the command RCPT to the SMTP server with the TO: argument of $to. * Returns true if the recipient was accepted false if it was rejected. * * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> * * SMTP CODE SUCCESS: 250,251 * SMTP CODE FAILURE: 550,551,552,553,450,451,452 * SMTP CODE ERROR : 500,501,503,421 * @access public * @return bool */ public function Recipient($to) { $this->error = null; // so no confusion is caused if (! $this->connected ()) { $this->error = array ("error" => "Called Recipient() without being connected" ); return false; } fputs ( $this->smtp_conn, "RCPT TO:<" . $to . ">" . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 250 && $code != 251) { $this->error = array ("error" => "RCPT not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } return true; } /** * Sends the RSET command to abort and transaction that is * currently in progress. Returns true if successful false * otherwise. * * Implements rfc 821: RSET <CRLF> * * SMTP CODE SUCCESS: 250 * SMTP CODE ERROR : 500,501,504,421 * @access public * @return bool */ public function Reset() { $this->error = null; // so no confusion is caused if (! $this->connected ()) { $this->error = array ("error" => "Called Reset() without being connected" ); return false; } fputs ( $this->smtp_conn, "RSET" . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 250) { $this->error = array ("error" => "RSET failed", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } return true; } /** * Starts a mail transaction from the email address specified in * $from. Returns true if successful or false otherwise. If True * the mail transaction is started and then one or more Recipient * commands may be called followed by a Data command. This command * will send the message to the users terminal if they are logged * in and send them an email. * * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF> * * SMTP CODE SUCCESS: 250 * SMTP CODE SUCCESS: 552,451,452 * SMTP CODE SUCCESS: 500,501,502,421 * @access public * @return bool */ public function SendAndMail($from) { $this->error = null; // so no confusion is caused if (! $this->connected ()) { $this->error = array ("error" => "Called SendAndMail() without being connected" ); return false; } fputs ( $this->smtp_conn, "SAML FROM:" . $from . $this->CRLF ); $rply = $this->get_lines (); $code = substr ( $rply, 0, 3 ); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; } if ($code != 250) { $this->error = array ("error" => "SAML not accepted from server", "smtp_code" => $code, "smtp_msg" => substr ( $rply, 4 ) ); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error ["error"] . ": " . $rply . $this->CRLF . '<br />'; } return false; } return true; } /** * This is an optional command for SMTP that this class does not * support. This method is here to make the RFC821 Definition * complete for this class and __may__ be implimented in the future * * Implements from rfc 821: TURN <CRLF> * * SMTP CODE SUCCESS: 250 * SMTP CODE FAILURE: 502 * SMTP CODE ERROR : 500, 503 * @access public * @return bool */ public function Turn() { $this->error = array ("error" => "This method, TURN, of the SMTP " . "is not implemented" ); if ($this->do_debug >= 1) { echo "SMTP -> NOTICE: " . $this->error ["error"] . $this->CRLF . '<br />'; } return false; } /** * Get the current error * @access public * @return array */ public function getError() { return $this->error; } ///////////////////////////////////////////////// // INTERNAL FUNCTIONS ///////////////////////////////////////////////// /** * Read in as many lines as possible * either before eof or socket timeout occurs on the operation. * With SMTP we can tell if we have more lines to read if the * 4th character is '-' symbol. If it is a space then we don't * need to read anything else. * @access private * @return string */ private function get_lines() { $data = ""; while ( $str = @fgets ( $this->smtp_conn, 515 ) ) { if ($this->do_debug >= 4) { echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />'; echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />'; } $data .= $str; if ($this->do_debug >= 4) { echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; } // if 4th character is a space, we are done reading, break the loop if (substr ( $str, 3, 1 ) == " ") { break; } } return $data; } } ?>
12ik
trunk/core/PHPMailer/class.smtp.php
PHP
oos
24,318
<?php /** * PHPMailer language file: refer to English translation for definitive list * Simplified Chinese Version * @author liqwei <liqwei@liqwei.com> */ $PHPMAILER_LANG ['authenticate'] = 'SMTP 错误:登录失败。'; $PHPMAILER_LANG ['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。'; $PHPMAILER_LANG ['data_not_accepted'] = 'SMTP 错误:数据不被接受。'; //$P$PHPMAILER_LANG['empty_message'] = 'Message body empty'; $PHPMAILER_LANG ['encoding'] = '未知编码: '; $PHPMAILER_LANG ['execute'] = '无法执行:'; $PHPMAILER_LANG ['file_access'] = '无法访问文件:'; $PHPMAILER_LANG ['file_open'] = '文件错误:无法打开文件:'; $PHPMAILER_LANG ['from_failed'] = '发送地址错误:'; $PHPMAILER_LANG ['instantiate'] = '未知函数调用。'; //$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: '; $PHPMAILER_LANG ['mailer_not_supported'] = '发信客户端不被支持。'; $PHPMAILER_LANG ['provide_address'] = '必须提供至少一个收件人地址。'; $PHPMAILER_LANG ['recipients_failed'] = 'SMTP 错误:收件人地址错误:'; //$PHPMAILER_LANG['signing'] = 'Signing Error: '; //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; ?>
12ik
trunk/core/PHPMailer/language/phpmailer.lang-zh_cn.php
PHP
oos
1,430
<?php /** * PHPMailer language file: refer to English translation for definitive list * Traditional Chinese Version * @author liqwei <liqwei@liqwei.com> */ $PHPMAILER_LANG ['authenticate'] = 'SMTP 錯誤:登錄失敗。'; $PHPMAILER_LANG ['connect_host'] = 'SMTP 錯誤:無法連接到 SMTP 主機。'; $PHPMAILER_LANG ['data_not_accepted'] = 'SMTP 錯誤:數據不被接受。'; //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; $PHPMAILER_LANG ['encoding'] = '未知編碼: '; $PHPMAILER_LANG ['file_access'] = '無法訪問文件:'; $PHPMAILER_LANG ['file_open'] = '文件錯誤:無法打開文件:'; $PHPMAILER_LANG ['from_failed'] = '發送地址錯誤:'; $PHPMAILER_LANG ['execute'] = '無法執行:'; $PHPMAILER_LANG ['instantiate'] = '未知函數調用。'; //$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: '; $PHPMAILER_LANG ['provide_address'] = '必須提供至少一個收件人地址。'; $PHPMAILER_LANG ['mailer_not_supported'] = '發信客戶端不被支持。'; $PHPMAILER_LANG ['recipients_failed'] = 'SMTP 錯誤:收件人地址錯誤:'; //$PHPMAILER_LANG['signing'] = 'Signing Error: '; //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; ?>
12ik
trunk/core/PHPMailer/language/phpmailer.lang-zh.php
PHP
oos
1,429
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); class IKImage { //图片类型 var $type; //实际宽度 var $width; //实际高度 var $height; //改变后的宽度 var $resize_width; //改变后的高度 var $resize_height; //是否裁图 var $cut; //源图象 var $srcimg; //目标图象地址 var $dstimg; //临时创建的图象 var $im; //截图的x坐标位置 var $srcX; //截图的y坐标位置 var $srcY; //源图象的宽度 var $srcW; //源图象的高度 var $srcH; //是否按比例截图 var $isRatio; //构造函数 public function __construct($img, $wid, $hei, $c, $dstpath,$srcX=0,$srcY=0, $srcW=0, $srcH=0, $isRatio=0) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; //图片截取x和y坐标 $this->srcX = $srcX; $this->srcY = $srcY; $this->srcW = $srcW; $this->srcH = $srcH; $this->isRatio = $isRatio; //图片的类型 $this->type = strtolower ( substr ( strrchr ( $this->srcimg, "." ), 1 ) ); //初始化图象 $this->initi_img (); //目标图象地址 $this->dst_img ( $dstpath ); //-- $this->width = imagesx ( $this->im ); $this->height = imagesy ( $this->im ); //生成图象 $this->newimg (); ImageDestroy ( $this->im ); } function newimg() { //改变后的图象的比例 $resize_ratio = ($this->resize_width) / ($this->resize_height); //实际图象的比例 $ratio = ($this->width) / ($this->height); if (($this->cut) == "1") //裁图 { if(($this->isRatio) == "1") { //echo $this->srcX.'-'.$this->srcY.'-'.$this->srcW.'='.$this->resize_width.'+'.$this->resize_height; //指定 srcW 和 srcH 截图 $newimg = imagecreatetruecolor ( $this->resize_width, $this->resize_height ); //int imagecopyresampled ( resource dst_im, resource src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) imagecopyresampled ( $newimg, $this->im, 0, 0, $this->srcX, $this->srcY, $this->resize_width, $this->resize_height, $this->srcW, $this->srcH); ImageJpeg ( $newimg, $this->dstimg ); }else{ if ($ratio >= $resize_ratio) //高度优先 { $newimg = imagecreatetruecolor ( $this->resize_width, $this->resize_height ); imagecopyresampled ( $newimg, $this->im, 0, 0, $this->srcX, $this->srcY, $this->resize_width, $this->resize_height, (($this->height) * $resize_ratio), $this->height ); ImageJpeg ( $newimg, $this->dstimg ); } if ($ratio < $resize_ratio) //宽度优先 { $newimg = imagecreatetruecolor ( $this->resize_width, $this->resize_height ); imagecopyresampled ( $newimg, $this->im, 0, 0, $this->srcX, $this->srcY, $this->resize_width, $this->resize_height, $this->width, (($this->width) / $resize_ratio) ); ImageJpeg ( $newimg, $this->dstimg ); } } } else //不裁图 { if ($ratio >= $resize_ratio) { $newimg = imagecreatetruecolor ( $this->resize_width, ($this->resize_width) / $ratio ); imagecopyresampled ( $newimg, $this->im, 0, $this->srcX, $this->srcY, 0, $this->resize_width, ($this->resize_width) / $ratio, $this->width, $this->height ); ImageJpeg ( $newimg, $this->dstimg ); } if ($ratio < $resize_ratio) { $newimg = imagecreatetruecolor ( ($this->resize_height) * $ratio, $this->resize_height ); imagecopyresampled ( $newimg, $this->im, 0, $this->srcX, $this->srcY, 0, ($this->resize_height) * $ratio, $this->resize_height, $this->width, $this->height ); ImageJpeg ( $newimg, $this->dstimg ); } } } //初始化图象 By wanglijun 2012-4-10 function initi_img() { $targetInfo = @getimagesize ( $this->srcimg ); switch ($targetInfo ['mime']) { case 'image/jpeg' : $this->im = imagecreatefromjpeg ( $this->srcimg ); break; case 'image/gif' : $this->im = imagecreatefromgif ( $this->srcimg ); break; case 'image/png' : $this->im = imagecreatefrompng ( $this->srcimg ); break; case 'image/bmp' : $this->im = imagecreatefromwbmp ( $this->srcimg ); break; } } //图象目标地址 function dst_img($dstpath) { $full_length = strlen ( $this->srcimg ); $type_length = strlen ( $this->type ); $name_length = $full_length - $type_length; $name = substr ( $this->srcimg, 0, $name_length - 1 ); $this->dstimg = $dstpath; //echo $this->dstimg; } }
12ik
trunk/core/IKImage.php
PHP
oos
4,531
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12ik爱客网 网站核心函数 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ //AutoAppClass function aac($appname) { global $db; $class = $appname; $path = IKAPP . '/' . $appname . '/'; if (! class_exists ( $class )) { include_once $path . 'class.' . $class . '.php'; } if (! class_exists ( $class )) { return false; } $obj = new $class ( $db ); return $obj; unset ( $db ); } //editor Special info to html function editor2html($str) { global $db; //匹配本地图片 preg_match_all ( '/\[(photo)=(\d+)\]/is', $str, $photos ); foreach ( $photos [2] as $item ) { $strPhoto = aac ( 'photo' )->getPhotoForApp ( $item ); $str = str_replace ( "[photo={$item}]", '<a href="' . SITE_URL . 'uploadfile/photo/' . $strPhoto ['photourl'] . '" target="_blank"> <img class="thumbnail" src="' . SITE_URL . tsXimg ( $strPhoto ['photourl'], 'photo', '500', '500', $strPhoto ['path'] ) . '" title="' . $strTopic ['title'] . $item . '" /></a>', $str ); } //匹配附件 preg_match_all ( '/\[(attach)=(\d+)\]/is', $str, $attachs ); if ($attachs [2]) { foreach ( $attachs [2] as $aitem ) { $strAttach = aac ( 'attach' )->getOneAttach ( $aitem ); if ($strAttach ['isattach'] == '1') { $str = str_replace ( "[attach={$aitem}]", '<span class="attach_down">附件下载: <a href="' . SITE_URL . 'index.php?app=attach&ac=ajax&ts=down&attachid=' . $aitem . '" target="_blank">' . $strAttach ["attachname"] . '</a></span>', $str ); } else { $str = str_replace ( "[attach={$aitem}]", '', $str ); } } } $find = array ("http://", "-", '.', "/", '?', '=', '&' ); $replace = array ("", '_', '', '', '', '', '' ); preg_match_all ( '/\[(video)=(.*?)\]/is', $str, $video ); if ($video [2]) { foreach ( $video [2] as $aitem ) { //img play title $arr = explode ( ',', $aitem ); $id = str_replace ( $find, $replace, $arr [0] ); $html = '<div id="img_' . $id . '"><a href="javascript:void(0)" onclick="showVideo(\'' . $id . '\',\'' . $arr [1] . '\');"><img src="' . $arr [0] . '"/></a></div>'; $html .= '<div id="play_' . $id . '" style="display:none">' . $arr ['2'] . ' <a href="javascript:void(0)" onclick="showVideo(\'' . $id . '\',\'' . $arr [1] . '\');">收起</a> <div id="swf_' . $id . '"></div> </div>'; $str = str_replace ( "[video={$aitem}]", $html, $str ); } } preg_match_all ( '/\[(mp3)=(.*?)\]/is', $str, $music ); if ($music [2]) { foreach ( $music [2] as $aitem ) { //url title $arr = explode ( ',', $aitem ); $id = str_replace ( $find, $replace, $arr [0] ); //$mp3flash = '<div id="mp3img_'.$id.'"><a href="javascript:void(0)" onclick="showMp3(\''.$id.'\',\''.$arr[1].'\');"><img src="'.SITE_URL.'public/flash/music.gif" /></a></div>'; $mp3flash = '<div id="mp3swf_' . $id . '" class="mp3player"> <div>' . $arr [1] . ' <a href="' . $aitem . '" target="_blank">下载</a> </div> <object height="24" width="290" data="' . SITE_URL . 'public/flash/player.swf" type="application/x-shockwave-flash"> <param value="' . SITE_URL . 'public/flash/player.swf" name="movie"/> <param value="autostart=no&bg=0xCDDFF3&leftbg=0x357DCE&lefticon=0xF2F2F2&rightbg=0xF06A51&rightbghover=0xAF2910&righticon=0xF2F2F2&righticonhover=0xFFFFFF&text=0x357DCE&slider=0x357DCE&track=0xFFFFFF&border=0xFFFFFF&loader=0xAF2910&soundFile=' . $aitem . '" name="FlashVars"/> <param value="high" name="quality"/> <param value="false" name="menu"/> <param value="#FFFFFF" name="bgcolor"/> </object></div>'; $str = str_replace ( "[mp3={$aitem}]", $mp3flash, $str ); } } return $str; unset ( $db ); } //12IK Notice function tsNotice($notice, $button = '点击返回', $url = 'javascript:history.back(-1);', $isAutoGo = false) { global $app; global $IK_SITE; global $IK_APP; global $site_theme; global $skin; global $IK_USER; global $IK_SOFT; global $runTime; $title = '系统提示'; include pubTemplate ( 'notice' ); exit (); } //系统消息 function qiMsg($msg, $button = '点击返回>>', $url = 'javascript:history.back(-1);', $isAutoGo = false) { echo <<<EOT <html> <head> EOT; if ($isAutoGo) { echo "<meta http-equiv=\"refresh\" content=\"2;url=$url\" />"; } echo <<<EOT <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>网站信息 提示</title> <style type="text/css"> <!-- body { font-family: Arial; font-size: 12px; line-height:150%; text-align:center; } a{color:#555555;} .main { width:500px; background-color:#FFFFFF; font-size: 12px; color: #666666; margin:100px auto 0; list-style:none; padding:20px; } .main p { line-height: 18px; margin: 5px 20px; font-size:14px; } --> </style> </head> <body> <div class="main"> <p>$msg</p> <p><a href="$url">$button</a></p> </div> </body> </html> EOT; exit (); } /* * 分页函数 * * @param int $count 条目总数 * @param int $perlogs 每页显示条数目 * @param int $page 当前页码 * @param string $url 页码的地址 * @return unknown */ function pagination($count, $perlogs, $page, $url, $suffix = '') { $pnums = @ceil ( $count / $perlogs ); $re = ''; for($i = $page - 5; $i <= $page + 5 && $i <= $pnums; $i ++) { if ($i > 0) { if ($i == $page) { $re .= ' <span class="current">' . $i . '</span> '; } else { $re .= '<a href="' . $url . $i . $suffix . '">' . $i . '</a>'; } } } if ($page > 6) $re = '<a href="' . $url . '1' . $suffix . '" title="首页">&laquo;</a> ...' . $re; if ($page + 5 < $pnums) $re .= '... <a href="' . $url . $pnums . $suffix . '" title="尾页">&raquo;</a>'; if ($pnums <= 1) $re = ''; return $re; } //验证Email function valid_email($email) { if (preg_match ( '/^[A-Za-z0-9]+([._\-\+]*[A-Za-z0-9]+)*@([A-Za-z0-9-]+\.)+[A-Za-z0-9]+$/', $email )) { return true; } else { return false; } } //处理时间的函数 function getTime($btime, $etime) { if ($btime < $etime) { $stime = $btime; $endtime = $etime; } else { $stime = $etime; $endtime = $btime; } $timec = $endtime - $stime; $days = intval ( $timec / 86400 ); $rtime = $timec % 86400; $hours = intval ( $rtime / 3600 ); $rtime = $rtime % 3600; $mins = intval ( $rtime / 60 ); $secs = $rtime % 60; if ($days >= 1) { return $days . ' 天前'; } if ($hours >= 1) { return $hours . ' 小时前'; } if ($mins >= 1) { return $mins . ' 分钟前'; } if ($secs >= 1) { return $secs . ' 秒前'; } } //获取用户IP function getIp() { if (getenv ( 'HTTP_CLIENT_IP' ) && strcasecmp ( getenv ( 'HTTP_CLIENT_IP' ), 'unknown' )) { $PHP_IP = getenv ( 'HTTP_CLIENT_IP' ); } elseif (getenv ( 'HTTP_X_FORWARDED_FOR' ) && strcasecmp ( getenv ( 'HTTP_X_FORWARDED_FOR' ), 'unknown' )) { $PHP_IP = getenv ( 'HTTP_X_FORWARDED_FOR' ); } elseif (getenv ( 'REMOTE_ADDR' ) && strcasecmp ( getenv ( 'REMOTE_ADDR' ), 'unknown' )) { $PHP_IP = getenv ( 'REMOTE_ADDR' ); } elseif (isset ( $_SERVER ['REMOTE_ADDR'] ) && $_SERVER ['REMOTE_ADDR'] && strcasecmp ( $_SERVER ['REMOTE_ADDR'], 'unknown' )) { $PHP_IP = $_SERVER ['REMOTE_ADDR']; } preg_match ( "/[\d\.]{7,15}/", $PHP_IP, $ipmatches ); $PHP_IP = $ipmatches [0] ? $ipmatches [0] : 'unknown'; return $PHP_IP; } //过滤脚本代码 function cleanJs($text) { $text = trim ( $text ); $text = stripslashes ( $text ); //完全过滤注释 $text = preg_replace ( '/<!--?.*-->/', '', $text ); //完全过滤动态代码 $text = preg_replace ( '/<\?|\?>/', '', $text ); //完全过滤js $text = preg_replace ( '/<script?.*\/script>/', '', $text ); //过滤多余html $text = preg_replace ( '/<\/?(html|head|meta|link|base|body|title|style|script|form|iframe|frame|frameset)[^><]*>/i', '', $text ); //过滤on事件lang js while ( preg_match ( '/(<[^><]+)(lang|onfinish|onmouse|onexit|onerror|onclick|onkey|onload|onchange|onfocus|onblur)[^><]+/i', $text, $mat ) ) { $text = str_replace ( $mat [0], $mat [1], $text ); } while ( preg_match ( '/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i', $text, $mat ) ) { $text = str_replace ( $mat [0], $mat [1] . $mat [3], $text ); } return $text; } //纯文本输入 function t($text) { $text = cleanJs ( $text ); //彻底过滤空格BY xiomai $text = preg_replace ( '/\s(?=\s)/', '', $text ); $text = preg_replace ( '/[\n\r\t]/', ' ', $text ); $text = str_replace ( ' ', ' ', $text ); $text = str_replace ( ' ', '', $text ); $text = str_replace ( '&nbsp;', '', $text ); $text = str_replace ( '&', '', $text ); $text = str_replace ( '=', '', $text ); $text = str_replace ( '-', '', $text ); $text = str_replace ( '#', '', $text ); $text = str_replace ( '%', '', $text ); $text = str_replace ( '!', '', $text ); $text = str_replace ( '@', '', $text ); $text = str_replace ( '^', '', $text ); $text = str_replace ( '*', '', $text ); $text = str_replace ( 'amp;', '', $text ); $text = strip_tags ( $text ); $text = htmlspecialchars ( $text ); $text = str_replace ( "'", "", $text ); return $text; } //输入安全的html,针对存入数据库中的数据进行的过滤和转义 function h($text) { $text = trim ( $text ); $text = htmlspecialchars ( $text ); $text = addslashes ( $text ); return $text; } //主要针对输出的内容,对动态脚本,静态html,动态语言全部通吃 function hview($text) { $text = stripslashes ( $text ); //删除反斜杠 $text = nl2br ( $text ); return $text; } //反序列化为UTF-8 function mb_unserialize($serial_str) { $serial_str = preg_replace ( '!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str ); $serial_str = str_replace ( "\r", "", $serial_str ); return unserialize ( $serial_str ); } //反序列化为ASC function asc_unserialize($serial_str) { $serial_str = preg_replace ( '!s:(\d+):"(.*?)";!se', '"s:".strlen("$2").":\"$2\";"', $serial_str ); $serial_str = str_replace ( "\r", "", $serial_str ); return unserialize ( $serial_str ); } //utf-8截取 function getsubstrutf8($string, $start = 0, $sublen, $append = true) { $pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/"; preg_match_all ( $pa, $string, $t_string ); if (count ( $t_string [0] ) - $start > $sublen && $append == true) { return join ( '', array_slice ( $t_string [0], $start, $sublen ) ) . "..."; } else { return join ( '', array_slice ( $t_string [0], $start, $sublen ) ); } } //计算时间 function getmicrotime() { list ( $usec, $sec ) = explode ( " ", microtime () ); return (( float ) $usec + ( float ) $sec); } /*写入文件 @By 小麦 2012-4-10 @$file 缓存文件 @$dir 缓存目录 @$data 内容 */ function fileWrite($file, $dir, $data) { //! is_dir ( $dir ) ? mkdir ( $dir, 0777 ) : ''; if(!is_dir($dir)) { @mkdir ( $dir, 0777 ); @chmod ( $dir, 0777 ); } $dfile = $dir . '/' . $file; if (is_file ( $dfile )) unlink ( $dfile ); $data = "<?php\ndefined('IN_IK') or die('Access Denied.');\nreturn " . var_export ( $data, true ) . ";"; file_put_contents ( $dfile, $data ); return true; } /*读取文件 @$dfile 文件 */ function fileRead($dfile) { if (is_file ( $dfile )) { $data = include $dfile; return $data; } } //把数组转换为,号分割的字符串 function array_to_str($arr) { $str = ''; $count = 1; if (is_array ( $arr )) { foreach ( $arr as $a ) { if ($count == 1) { $str .= $a; } else { $str .= ',' . $a; } $count ++; } } return $str; } //生成随机数(1数字,0字母数字组合) function random($length, $numeric = 0) { PHP_VERSION < '4.2.0' ? mt_srand ( ( double ) microtime () * 1000000 ) : mt_srand (); $seed = base_convert ( md5 ( print_r ( $_SERVER, 1 ) . microtime () ), 16, $numeric ? 10 : 35 ); $seed = $numeric ? (str_replace ( '0', '', $seed ) . '012340567890') : ($seed . 'zZ' . strtoupper ( $seed )); $hash = ''; $max = strlen ( $seed ) - 1; for($i = 0; $i < $length; $i ++) { $hash .= $seed [mt_rand ( 0, $max )]; } return $hash; } /* *封装一个采集函数 *@ $url 网址 *@ $proxy 代理 *@ $timeout 跳出时间 */ function getHtmlByCurl($url, $proxy, $timeout) { $ch = curl_init (); curl_setopt ( $ch, CURLOPT_PROXY, $proxy ); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, $timeout ); $file_contents = curl_exec ( $ch ); // close curl resource, and free up system resources curl_close($ch); return $file_contents; } //计算文件大小 function format_bytes($size) { $units = array (' B', ' KB', ' MB', ' GB', ' TB' ); for($i = 0; $size >= 1024 && $i < 4; $i ++) $size /= 1024; return round ( $size, 2 ) . $units [$i]; } /* * 功能: 判断是否是手机访问 * 参数: 无 * 返回值: 返回1为是手机访问,返回0时为不是 */ function is_wap() { $http_via = isset ( $_SERVER ['HTTP_VIA'] ) ? strtolower ( $_SERVER ['HTTP_VIA'] ) : ''; return ! empty ( $http_via ) && strstr ( $http_via, 'wap' ) ? 1 : 0; } //object_array 对象转数组 function object_array($array) { if (is_object ( $array )) { $array = ( array ) $array; } if (is_array ( $array )) { foreach ( $array as $key => $value ) { $array [$key] = object_array ( $value ); } } return $array; } /*此处开始借用moophp的模板代码*/ /** * 写文件 * @param string $file - 需要写入的文件,系统的绝对路径加文件名 * @param string $content - 需要写入的内容 * @param string $mod - 写入模式,默认为w * @param boolean $exit - 不能写入是否中断程序,默认为中断 * @return boolean 返回是否写入成功 */ function isWriteFile($file, $content, $mod = 'w', $exit = TRUE) { if (! @$fp = @fopen ( $file, $mod )) { if ($exit) { exit ( '12IK File :<br>' . $file . '<br>Have no access to write!' ); } else { return false; } } else { @flock ( $fp, 2 ); @fwrite ( $fp, $content ); @fclose ( $fp ); return true; } } //创建目录 function makedir($dir) { return is_dir ( $dir ) or (makedir ( dirname ( $dir ) ) and mkdir ( $dir, 0777 ) and chmod ( $dir, 0777 )); } /** * 加载模板 * @param string $file - 模板文件名 * @return string 返回编译后模板的系统绝对路径 */ function template($file) { global $app; $tplfile = 'app/' . $app . '/html/' . $file . '.html'; $objfile = 'cache/templates/' . $app . '.' . $file . '.tpl.php'; if (@filemtime ( $tplfile ) > @filemtime ( $objfile )) { //note 加载模板类文件 require_once 'core/class.template.php'; $T = new template (); $T->complie ( $tplfile, $objfile ); } return $objfile; unset ( $app ); } //加载公用html模板文件 function pubTemplate($file) { $tplfile = 'public/html/' . $file . '.html'; $objfile = 'cache/templates/public.' . $file . '.tpl.php'; if (@filemtime ( $tplfile ) > @filemtime ( $objfile )) { //note 加载模板类文件 require_once 'core/class.template.php'; $T = new template (); $T->complie ( $tplfile, $objfile ); } return $objfile; } //针对app各个的插件部分,修改自Emlog /** * 该函数在插件中调用,挂载插件函数到预留的钩子上 * * @param string $hook * @param string $actionFunc * @return boolearn */ function addAction($hook, $actionFunc) { global $tsHooks; if (! @in_array ( $actionFunc, $tsHooks [$hook] )) { $tsHooks [$hook] [] = $actionFunc; } return true; } /** * 执行挂在钩子上的函数,支持多参数 eg:doAction('post_comment', $author, $email, $url, $comment); * * @param string $hook */ function doAction($hook) { global $tsHooks; $args = array_slice ( func_get_args (), 1 ); if (isset ( $tsHooks [$hook] )) { foreach ( $tsHooks [$hook] as $function ) { $string = call_user_func_array ( $function, $args ); } } } function createFolders($path) { //递归创建 if (! file_exists ( $path )) { createFolders ( dirname ( $path ) ); //取得最后一个文件夹的全路径返回开始的地方 mkdir ( $path, 0777 ); } } //删除文件夹和文件夹下所有的文件 function delDir($dir = '') { if (empty ( $dir )) { $dir = rtrim ( RUNTIME_PATH, '/' ); } if (substr ( $dir, - 1 ) == '/') { $dir = rtrim ( $dir, '/' ); } if (! file_exists ( $dir )) return true; if (! is_dir ( $dir ) || is_link ( $dir )) return @unlink ( $dir ); foreach ( scandir ( $dir ) as $item ) { if ($item == '.' || $item == '..') continue; if (! delDir ( $dir . "/" . $item )) { @chmod ( $dir . "/" . $item, 0777 ); if (! delDir ( $dir . "/" . $item )) return false; } ; } return @rmdir ( $dir ); } //获取带http的网站域名 BY wanglijun function getHttpUrl(){ $arrUri = explode('index.php',$_SERVER['REQUEST_URI']); $site_url = 'http://'.$_SERVER['HTTP_HOST'].$arrUri[0]; return $site_url; } // 10位MD5值 function md10($str = '') { return substr ( md5 ( $str ), 10, 10 ); } /* * 12IK专用图片截图函数 * $file:数据库里的图片url * $app:app名称 * $w:缩略图片宽度 * $h:缩略图片高度 * $c:1裁切,0不裁切 * $srcX:x坐标 * $srcY:y坐标 * $srcW:截图宽 * $isRatio:1 安指定比例截图 0 等比截图 * $conditions 数组形式 arrary('srcX'=>0, 'srcY'=>0, 'srcW'=>0, 'isRatio'=>0) */ function tsXimg($file, $app, $w, $h, $path = '', $c = '0', $conditions='') { if (! $file) { return; } $info = explode ( '.', $file ); $name = md10 ( $file ) . '_' . $w . '_' . $h . '.' . $info [1]; if ($path == '') { $cpath = 'cache/' . $app . '/' . $w . '/' . $name; } else { $cpath = 'cache/' . $app . '/' . $path . '/' . $w . '/' . $name; } //条件 if (is_array ( $conditions ) && !empty($conditions)){ $srcX = $conditions['X']; $srcY = $conditions['Y']; $srcW = $conditions['W']; $srcH = $conditions['H']; $isRatio = $conditions['R']; } //不截图 if($isRatio==0) { if (! is_file ( $cpath )) { createFolders ( 'cache/' . $app . '/' . $path . '/' . $w ); $dest = 'uploadfile/' . $app . '/' . $file; $arrImg = getimagesize ( $dest ); if ($arrImg [0] <= $w) { copy ( $dest, $cpath ); } else { require_once 'core/IKImage.php'; $resizeimage = new IKImage ( "$dest", $w, $h, $c, "$cpath"); } } }else{ //截图 if (! is_file ( $cpath )) { createFolders ( 'cache/' . $app . '/' . $path . '/' . $w ); require_once 'core/IKImage.php'; $resizeimage = new IKImage ( "$file", $w, $h, $c, "$cpath", $srcX, $srcY,$srcW,$srcH, $isRatio); } } return $cpath; } //gzip压缩输出 function ob_gzip($content) { if (! headers_sent () && extension_loaded ( "zlib" ) && strstr ( $_SERVER ["HTTP_ACCEPT_ENCODING"], "gzip" )) { //$content = gzencode($content." \n//此页已压缩",9); $content = gzencode ( $content, 9 ); header ( "Content-Encoding: gzip" ); header ( "Vary: Accept-Encoding" ); header ( "Content-Length: " . strlen ( $content ) ); } return $content; } /* tsUrl() By 12ik * tsUrl提供至少4种的url展示方式 * (1)index.php?app=group&ac=topic&topicid=1 //标准默认模式 * (2)index.php/group/topic/topicid-1 //path_info模式 * (3)group-topic-topicid-1.html //rewrite模式1 * (4)group/topic/ts-user/topicid-1/ //rewrite模式2 * (5)group/topic/1 //rewrite模式2 * (6)group/topic/id/1 //rewrite模式2 * (7)group/topic/1/ //rewrite模式2 */ function tsUrl($app, $ac = '', $params = array()) { //global $IK_SITE; //echo $IK_SITE['base']['site_urltype']; if (is_file ( 'data/system_options.php' )) { $options = include 'data/system_options.php'; } else { $options = include 'data/cache/system/options.php'; } $urlset = $options ['site_urltype']; if($urlset==1){ foreach($params as $k=>$v){ $str .= '&'.$k.'='.$v; } if($ac==''){ $ac = ''; }else{ $ac='&ac='.$ac; } $url = 'index.php?app='.$app.$ac.$str; }elseif($urlset == 2){ foreach($params as $k=>$v){ $str .= '/'.$k.'-'.$v; } if($ac==''){ $ac=''; }else{ $ac='/'.$ac; } $url = 'index.php/'.$app.$ac.$str; }elseif($urlset == 3){ foreach($params as $k=>$v){ $str .= '-'.$k.'-'.$v; } if($ac==''){ $ac=''; }else{ $ac='-'.$ac; } $page = strpos($str,'page'); if($page){ $url = $app.$ac.$str; }else{ $url = $app.$ac.$str.'.html'; } }elseif($urlset == 4){ foreach($params as $k=>$v){ $str .= '/'.$k.'-'.$v; } if($ac==''){ $ac=''; }else{ $ac='/'.$ac; } $url = $app.$ac.$str; }elseif($urlset == 5){ foreach($params as $k=>$v){ $str .= '/'.$k.'/'.$v; } $str=str_replace('/id','',$str); if($ac==''){ $ac=''; }else{ $ac='/'.$ac; } $url = $app.$ac.$str; }elseif($urlset == 6){ foreach($params as $k=>$v){ $str .= '/'.$k.'/'.$v; } if($ac==''){ $ac=''; }else{ $ac='/'.$ac; } $url = $app.$ac.$str; }elseif($urlset == 7){ foreach($params as $k=>$v){ $str .= '/'.$k.'/'.$v; } $str=str_replace('/id','',$str); $str=str_replace('/ts','',$str); if($ac==''){ $ac=''; }else{ $ac='/'.$ac; } $page = strpos($str,'page'); if($page){ $url = $app.$ac.$str; }else{ $url = $app.$ac.$str.'/'; } } return $url; } //reurl BY Charm 2012-4-10 function reurl(){ $options = fileRead('data/system_options.php'); $scriptName = explode('index.php',$_SERVER['SCRIPT_NAME']); $rurl = substr($_SERVER['REQUEST_URI'], strlen($scriptName[0])); if(strpos($rurl,'?')==false){ if(preg_match('/index.php/i',$rurl)){ $rurl = str_replace('index.php','',$rurl); $rurl = substr($rurl, 1); $params = $rurl; }else{ $params = $rurl; } if($rurl){ if($options['site_urltype']==3){ //http://localhost/group-topic-id-1.html $params = explode('.', $params); $params = explode('-', $params[0]); foreach( $params as $p => $v ){ switch($p){ case 0:$_GET['app']=$v;break; case 1:$_GET['ac']=$v;break; default: if($v) $kv[] = $v; break; } } $ck = count($kv)/2; if($ck>=2){ $arrKv = array_chunk($kv,$ck); foreach($arrKv as $key=>$item){ $_GET[$item[0]] = $item[1]; } }elseif($ck==1){ $_GET[$kv[0]] = $kv[1]; }else{ } }elseif($options['site_urltype']==4){ //http://localhost/group/topic/id-1 $params = explode('/', $params); foreach( $params as $p => $v ){ switch($p){ case 0:$_GET['app']=$v;break; case 1:$_GET['ac']=$v;break; default: $kv = explode('-', $v); if(count($kv)>1){ $_GET[$kv[0]] = $kv[1]; }else{ $_GET['params'.$p] = $kv[0]; } break; } } }elseif($options['site_urltype']==5){ //http://localhost/group/topic/1 $params = explode('/', $params); foreach( $params as $p => $v ){ switch($p){ case 0:$_GET['app']=$v;break; case 1:$_GET['ac']=$v; if(empty($_GET['ac'])) $_GET['ac']='index'; break; case 2: if(((int) $v)>0){ $_GET['id']=$v; break; } default: $_GET[$v]=$params[$p+1]; break; } } }elseif($options['site_urltype']==6){ //http://localhost/group/topic/id/1 $params = explode('/', $params); foreach( $params as $p => $v ){ switch($p){ case 0:$_GET['app']=$v;break; case 1:$_GET['ac']=$v;break; default: $_GET[$v]=$params[$p+1]; break; } } }elseif($options['site_urltype']==7){ //http://localhost/group/topic/1/ $params = explode('/', $params); foreach( $params as $p => $v ){ //echo $p.'='.$v.'<br/>'; switch($p){ case 0: $_GET['app']=$v; break; case 1: $_GET['ac']=$v;//默认 //echo $_GET['app'].'------------'; if(empty($_GET['ac'])) { $_GET['ac']='index'; } /*else if(((int) $v)>0){ $_GET['ac']='index'; $_GET['id']=$v; } */ else if($_GET['app']=='hi' && $params[2]=='') { $_GET['ac']='index'; $_GET['id']=$v; } break; case 2: if(((int) $v)>0){ $_GET['id']=$v; break; } if(is_string($v) && !empty($v)) { $paramid = substr($v, strlen($v)-2); if($paramid!='id') { $_GET['ts']=$v; break; } } default: $_GET[$v]=$params[$p+1]; break; } } }else{ $params = explode('/', $params); foreach( $params as $p => $v ){ switch($p){ case 0:$_GET['app']=$v;break; case 1:$_GET['ac']=$v;break; default: $kv = explode('-', $v); if(count($kv)>1){ $_GET[$kv[0]] = $kv[1]; }else{ $_GET['params'.$p] = $kv[0]; } break; } } } } } } //检测目录是否可写1可写,0不可写 function iswriteable($file) { if (is_dir ( $file )) { $dir = $file; if ($fp = fopen ( "$dir/test.txt", 'w' )) { fclose ( $fp ); unlink ( "$dir/test.txt" ); $writeable = 1; } else { $writeable = 0; } } else { if ($fp = fopen ( $file, 'a+' )) { fclose ( $fp ); $writeable = 1; } else { $writeable = 0; } } return $writeable; } //删除目录下文件 function delDirFile($dir) { $arrFiles = dirList ( $dir, 'files' ); foreach ( $arrFiles as $item ) { unlink ( $dir . '/' . $item ); } } /* * 12IK专用上传函数 * $file 要上传的文件 如$_FILES['photo'] * $projectid 上传针对的项目id 如$userid * $dir 上传到目录 如 user * $uptypes 上传类型,数组 array('jpg','png','gif') * * 返回数组:array('name'=>'','path'=>'','url'=>'','path'=>'','size'=>'') */ function tsUpload($files, $projectid, $dir, $uptypes) { //ClearOptCache('group'); if (! empty ( $files )) { $menu2 = intval ( $projectid / 1000 ); $menu1 = intval ( $menu2 / 1000 ); $path = $menu1 . '/' . $menu2; $dest_dir = 'uploadfile/' . $dir . '/' . $path; createFolders ( $dest_dir ); $arrType = explode('.',strtolower($files['name'])); //转小写一下 $type = array_pop ( $arrType ); if (in_array ( $type, $uptypes )) { $name = $projectid . '.' . $type; $dest = $dest_dir . '/' . $name; //先删除 unlink($dest); //后上传 move_uploaded_file ( $files ['tmp_name'], mb_convert_encoding ( $dest, "gb2312", "UTF-8" ) ); // 所有者有所有权限,其他所有人可读和执行 chmod ( $dest, 0755 );//chmod($dest, 0777); return array ('name' => $name, 'path' => $path, 'url' => $path . '/' . $name, 'type' => $type, 'size' => $files ['size'] ); } else { return false; } } } //扫描目录 function tsScanDir($dir, $isDir = null) { if ($isDir == null) { $dirs = array_filter ( glob ( $dir . '/' . '*' ), 'is_dir' ); } else { $dirs = array_filter ( glob ( $dir . '/' . '*' ), 'is_file' ); } foreach ( $dirs as $key => $item ) { $arrDirs [] = array_pop ( explode ( '/', $item ) ); } return $arrDirs; } //删除目录下所有文件 function rmrf($dir) { foreach ( glob ( $dir ) as $file ) { if (is_dir ( $file )) { rmrf ( "$file/*" ); rmdir ( $file ); } else { unlink ( $file ); } } } /** * 修改于 2012-4-13 小麦 * 清除指定路径缓存 用法: ClearAppCache($app.'/'.$arrUpload['path']); * @param string $dir - 路径名 * @return true 返回 true 成功 false 失败 */ function ClearAppCache($dir) { $cachedir = 'cache/'.$dir; foreach ( glob ( $cachedir ) as $file ) { if (is_dir ( $file )) { //echo $file; rmrf ( "$file/*" ); rmdir ( $file ); } else { unlink ( $file ); } return TRUE; } return FALSE; } //限制输入字符长度,防止缓冲区溢出攻击 function LenLimit($Str,$MaxSlen){ if(isset($Str{$MaxSlen})){ return " "; }else{ return $Str; } } //post,get对象过滤通用函数 function long_check($post) { $MaxSlen=3000;//限制较长输入项最多3000个字符 if (!get_magic_quotes_gpc()) // 判断magic_quotes_gpc是否为打开 { $post = addslashes($post); // 进行magic_quotes_gpc没有打开的情况对提交数据的过滤 } $post = LenLimit($post,$MaxSlen); $post = str_replace("\'", "’", $post); $post= htmlspecialchars($post); // 将html标记转换为可以显示在网页上的html //$post = nl2br($post); // 回车 return $post; } function big_check($post){ $MaxSlen=20000;//限制大输入项最多20000个字符 if (!get_magic_quotes_gpc()) // 判断magic_quotes_gpc是否为打开 { $post = addslashes($post); // 进行magic_quotes_gpc没有打开的情况对提交数据的过滤 } $post = LenLimit($post,$MaxSlen); $post = str_replace("\'", "’", $post); $post = str_replace("<script ", "", $post); $post = str_replace("</script ", "", $post); return $post; } function short_check($str) { $MaxSlen=500;//限制短输入项最多300个字符 if (!get_magic_quotes_gpc()) // 判断magic_quotes_gpc是否打开 { $str = addslashes($str); // 进行过滤 } $str = LenLimit($str,$MaxSlen); $str = str_replace(array("\'","\\","#"),"",$str); if($str!=''){ $str= htmlspecialchars($str); } return preg_replace("/ +/","",trim($str)); } function filter_script($str){ return preg_replace(array('/<\s*script/','/<\s*\/\s*script\s*>/',"/<\?/","/\?>/"),array("&lt;script","&lt;/script&gt;","&lt;?","?&gt;"),$str); } //过滤16进制 function cleanHex($input){ $clean = preg_replace("![\][xX]([A-Fa-f0-9]{1,3})!", "",$input); return $clean; } //多余字截取函数 function sub_str($str, $length = 0, $append = true, $charset='utf8') { $str = trim($str); $strlength = strlen($str); $charset = strtolower($charset); if ($charset == 'utf8') { $l = 0; $i = 0; while ($i < $strlength) { if (ord($str{$i}) < 0x80) { $l++; $i++; } else if (ord($str{$i}) < 0xe0) { $l++; $i += 2; } else if (ord($str{$i}) < 0xf0) { $l += 2; $i += 3; } else if (ord($str{$i}) < 0xf8) { $l += 1; $i += 4; } else if (ord($str{$i}) < 0xfc) { $l += 1; $i += 5; } else if (ord($str{$i}) < 0xfe) { $l += 1; $i += 6; } if ($l >= $length) { $newstr = substr($str, 0, $i); break; } } if($l < $length) { return $str; } } elseif($charset == 'gbk') { if ($length == 0 || $length >= $strlength) { return $str; } while ($i <= $strlength) { if (ord($str{$i}) > 0xa0) { $l += 2; $i += 2; } else { $l++; $i++; } if ($l >= $length) { $newstr = substr($str, 0, $i); break; } } } if ($append && $str != $newstr) { $newstr .= '..'; } return $newstr; } function str_addslashes($str) { if(!get_magic_quotes_gpc()) { if(is_array($str)) { foreach($str as $key => $val) { $str[$key] = str_addslashes($val); } } else { $str = addslashes($str); } } return $str; } function str_filter($str,$max_num='20000'){ if(is_array($str)){ foreach($str as $key => $val) { $str[$key] = str_filter($val,$max_num); } }else{ $str = LenLimit($str,$max_num); $str = trim($str); $str = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1',htmlspecialchars($str)); $str = str_replace(" ","",$str); } return str_addslashes($str); } /** * html代码正常输出 * @param str * 用法:html_filter($_POST("detail")); <font color="red">1</font>正常方式输出 */ function html_filter($str,$max_num='20000'){ if(is_array($str)){ foreach($str as $key => $val){ $str[$key] = html_filter($val); } }else{ $str = LenLimit($str,$max_num); $str = trim($str); $tran_before = array('/<\s*a[^>]*href\s*=\s*[\'\"]?(javascript|vbscript)[^>]*>/i','/<([^>]*)on(\w)+=[^>]*>/i','/<\s*\/?\s*(script|i?frame)[^>]*\s*>/i'); $tran_after = array('<a href="#">','<$1>','&lt;$1&gt;'); $str = preg_replace($tran_before,$tran_after,$str); $str = str_replace(" ","",$str); } return str_addslashes($str); }
12ik
trunk/core/IKFunction.php
PHP
oos
33,628
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 爱客网 网站核心文件 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ class template { var $var_regexp = "\@?\\\$[a-zA-Z_][\\\$\w]*(?:\[[\w\-\.\"\'\[\]\$]+\])*"; var $vtag_regexp = "\<\?php echo (\@?\\\$[a-zA-Z_][\\\$\w]*(?:\[[\w\-\.\"\'\[\]\$]+\])*)\;\?\>"; var $const_regexp = "\{([\w]+)\}"; /** * 读模板页进行替换后写入到cache页里 * * @param string $tplfile :模板源文件地址 * @param string $objfile :模板cache文件地址 * @return string */ function complie($tplfile, $objfile) { $template = file_get_contents ( $tplfile ); $template = $this->parse ( $template ); makedir ( dirname ( $objfile ) ); isWriteFile ( $objfile, $template, $mod = 'w', TRUE ); } /** * 解析模板标签 * * @param string $template :模板源文件内容 * @return string */ function parse($template) { //BY wanglijun 2012-04-11 增加tsurl路由模板标签 $template = preg_replace ( "/\{tsUrl(.*?)\}/s", "{php echo tsurl\\1}", $template ); $template = preg_replace ( "/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template ); //去除html注释符号<!----> $template = preg_replace ( "/\{($this->var_regexp)\}/", "<?php echo \\1;?>", $template ); //替换带{}的变量 $template = preg_replace ( "/\{($this->const_regexp)\}/", "<?php echo \\1;?>", $template ); //替换带{}的常量 $template = preg_replace ( "/(?<!\<\?php echo |\\\\)$this->var_regexp/", "<?php echo \\0;?>", $template ); //替换重复的<?php echo $template = preg_replace ( "/\{php (.*?)\}/ies", "\$this->stripvTag('<?php \\1?>')", $template ); //替换php标签 $template = preg_replace ( "/\{for (.*?)\}/ies", "\$this->stripvTag('<?php for(\\1) {?>')", $template ); //替换for标签 $template = preg_replace ( "/\{elseif\s+(.+?)\}/ies", "\$this->stripvTag('<?php } elseif (\\1) { ?>')", $template ); //替换elseif标签 for($i = 0; $i < 3; $i ++) { $template = preg_replace ( "/\{loop\s+$this->vtag_regexp\s+$this->vtag_regexp\s+$this->vtag_regexp\}(.+?)\{\/loop\}/ies", "\$this->loopSection('\\1', '\\2', '\\3', '\\4')", $template ); $template = preg_replace ( "/\{loop\s+$this->vtag_regexp\s+$this->vtag_regexp\}(.+?)\{\/loop\}/ies", "\$this->loopSection('\\1', '', '\\2', '\\3')", $template ); } $template = preg_replace ( "/\{if\s+(.+?)\}/ies", "\$this->stripvTag('<?php if(\\1) { ?>')", $template ); //替换if标签 $template = preg_replace ( "/\{include\s+(.*?)\}/is", "<?php include \\1; ?>", $template ); //替换include标签 $template = preg_replace ( "/\{template\s+(\w+?)\}/is", "<?php include template('\\1'); ?>", $template ); //替换template标签 $template = preg_replace ( "/\{block (.*?)\}/ies", "\$this->stripBlock('\\1')", $template ); //替换block标签 $template = preg_replace ( "/\{else\}/is", "<?php } else { ?>", $template ); //替换else标签 $template = preg_replace ( "/\{\/if\}/is", "<?php } ?>", $template ); //替换/if标签 $template = preg_replace ( "/\{\/for\}/is", "<?php } ?>", $template ); //替换/for标签 $template = preg_replace ( "/$this->const_regexp/", "<?php echo \\1;?>", $template ); //note {else} 也符合常量格式,此处要注意先后顺?? $template = preg_replace ( "/(\\\$[a-zA-Z_]\w+\[)([a-zA-Z_]\w+)\]/i", "\\1'\\2']", $template ); //将二维数组替换成带单引号的标准模式 /* $template = "<?php if(!defined('IN_IK')) exit('Access Denied');?>\r\n$template"; */ $template = "$template"; return $template; } /** * 正则表达式匹配替换 * * @param string $s : * @return string */ function stripvTag($s) { return preg_replace ( "/$this->vtag_regexp/is", "\\1", str_replace ( "\\\"", '"', $s ) ); } function stripTagQuotes($expr) { $expr = preg_replace ( "/\<\?php echo (\\\$.+?);\?\>/s", "{\\1}", $expr ); $expr = str_replace ( "\\\"", "\"", preg_replace ( "/\[\'([a-zA-Z0-9_\-\.\x7f-\xff]+)\'\]/s", "[\\1]", $expr ) ); return $expr; } function stripv($vv) { $vv = str_replace ( '<?php', '', $vv ); $vv = str_replace ( 'echo', '', $vv ); $vv = str_replace ( ';', '', $vv ); $vv = str_replace ( '?>', '', $vv ); return $vv; } /** * 将模板中的块替换成BLOCK函数 * * @param string $blockname : * @param string $parameter : * @return string */ function stripBlock($parameter) { return $this->stripTagQuotes ( "<?php Mooblock(\"$parameter\"); ?>" ); } /** * 替换模板中的LOOP循环 * * @param string $arr : * @param string $k : * @param string $v : * @param string $statement : * @return string */ function loopSection($arr, $k, $v, $statement) { $arr = $this->stripvTag ( $arr ); $k = $this->stripvTag ( $k ); $v = $this->stripvTag ( $v ); $statement = str_replace ( "\\\"", '"', $statement ); return $k ? "<?php foreach((array)$arr as $k=>$v) {?>$statement<?php }?>" : "<?php foreach((array)$arr as $v) {?>$statement<?php } ?>"; } }
12ik
trunk/core/class.template.php
PHP
oos
5,183
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' );
12ik
trunk/uploadfile/index.php
PHP
oos
55
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); switch ($ts) { case "user" : $userid = intval ( $_GET ['userid'] ); //获取用户信息 $strUser = aac('user')->getOneUser($userid); if($userid == 0) header("Location: ".SITE_URL."index.php"); //分页 $page = isset($_GET['page']) ? $_GET['page'] : '1'; $url = SITE_URL."index.php?app=note&ac=index&ts=user&userid=".$userid."&page="; $lstart = $page*10-10; $arrNotes = $db->fetch_all_assoc ( "select * from " . dbprefix . "note where `userid`='$userid' order by addtime desc limit $lstart, 10" ); foreach($arrNotes as $key=>$item){ $arrNote[] = $item; $arrNote[$key]['photo'] = $new['note']->getOnePhoto($item['content']); $arrNote[$key]['content'] = getsubstrutf8(t($item['content']),0,200); $arrNote[$key]['user'] = aac('user')->getOneUser($item['userid']); $arrNote[$key]['cate'] = $new['note']->getOneCate($item['cateid']); } $noteNum = $db->once_num_rows("select * from ".dbprefix."note where `userid`='$userid' "); $pageUrl = pagination($noteNum, 10, $page, $url); //我的日志分类 $arrCate = aac('note')->getArrCate($userid); if($IK_USER['user']['userid'] == $userid){ $title = '我的日志'; $userCateName = '我的日志分类'; }else{ $title = $strUser['username'].'的日志'; $userCateName = $strUser['username'].'的日志分类'; } include template ( 'index' ); break; }
12ik
trunk/app/note/action/index.php
PHP
oos
1,488
<?php defined('IN_IK') or die('Access Denied.'); //用户是否登录 $userid = aac('user')->isLogin(); switch($ts){ case "": //分类 $arrCate = $new['note']->getArrCate($userid); if ($arrCate==''){ $db->query("insert into ".dbprefix."note_cate (`userid`,`catename`) values ('$userid','默认分类')"); } $title = '写日志'; include template('add'); break; case "do": $cateid = $_POST['cateid']; $title = htmlspecialchars(trim($_POST['title'])); $content = $_POST['content']; $addtime = time(); if($title=='' || $content=='') qiMsg("标题和内容都不能为空!"); if(mb_strlen($title,'utf8')>64) tsNotice('标题很长很长很长很长...^_^'); if(mb_strlen($content,'utf8')>50000) tsNotice('发这么多内容干啥^_^'); $isphoto = 0; $isattach = 0; //判断是否有图片和附件 preg_match_all('/\[(photo)=(\d+)\]/is', $content, $photo); if($photo[2]){ $isphoto = '1'; } //判断附件 preg_match_all('/\[(attach)=(\d+)\]/is', $content, $attach); if($attach[2]){ $isattach = '1'; } //isaudit=0 代表审核未通过 $db->query("insert into ".dbprefix."note (`userid`,`cateid`,`title`,`content`,`isphoto`,`isattach`,`isaudit`,`addtime`) values ('$userid','$cateid','$title','$content','$isphoto','$isattach','0','$addtime')"); $noteid = $db->insert_id(); //处理标签 aac('tag')->addTag('note','noteid',$noteid,trim($_POST['tag'])); header("Location: ".SITE_URL.tsUrl('note','show',array('noteid'=>$noteid))); break; }
12ik
trunk/app/note/action/add.php
PHP
oos
1,616
<?php defined('IN_IK') or die('Access Denied.'); switch($ts){ case "list": //列表 $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $url = SITE_URL.'index.php?app=note&ac=admin&mg=note&ts=list&page='; $lstart = $page*10-10; //获取全部日志 $arrNote = $db->fetch_all_assoc("select * from ".dbprefix."note order by addtime desc limit $lstart,10"); $noteNum = $db->once_num_rows("select * from ".dbprefix."note"); echo $noteNum; include template("admin/note_list"); break; }
12ik
trunk/app/note/action/admin/note.php
PHP
oos
546
<?php defined('IN_IK') or die('Access Denied.'); /* * 配置选项 */ switch($ts){ //基本配置 case "": include template("admin/options"); break; }
12ik
trunk/app/note/action/admin/options.php
PHP
oos
180
<?php defined('IN_IK') or die('Access Denied.'); switch($ts){ case "list": //列表 $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $url = SITE_URL.'index.php?app=article&ac=admin&mg=cate&ts=list&page='; $lstart = $page*10-10; $arrCate = $db->fetch_all_assoc("select * from ".dbprefix."article_cate order by cateid desc limit $lstart, 10"); $cateNum = $db->once_fetch_assoc("select count(*) from ".dbprefix."article_cate"); $pageUrl = pagination($cateNum['count(*)'], 10, $page, $url); include template("admin/cate_list"); break; case "add": include template("admin/cate_add"); break; case "add_do": $catename = trim($_POST['catename']); $db->query("insert into ".dbprefix."article_cate (`catename`) values ('$catename')"); header("Location: ".SITE_URL.'index.php?app=article&ac=admin&mg=cate&ts=list'); break; case "edit": $cateid = $_GET['cateid']; $strCate = $db->once_fetch_assoc("select * from ".dbprefix."article_cate where `cateid`='$cateid'"); include template("admin/cate_edit"); break; case "edit_do": $cateid = $_POST['cateid']; $catename = trim($_POST['catename']); $db->query("update ".dbprefix."article_cate set `catename`='$catename' where `cateid`='$cateid'"); qiMsg("修改成功!"); break; }
12ik
trunk/app/note/action/admin/cate.php
PHP
oos
1,393
<?php defined('IN_IK') or die('Access Denied.'); //用户是否登录 $userid = aac('user')->isLogin(); switch($ts){ case "": $catename = $_GET['catename']; include template("add_ajax"); break; case "add": $catename = t($_POST['catename']); if($userid == '0'){ echo 0; }elseif(empty($catename)){ echo 1; }else{ $db->query("insert into ".dbprefix."note_cate (`userid`,`catename`) values ('".$userid."','".$catename."')"); $arrCate = $new['note']->getArrCate($userid); header("Content-Type: application/json", true); echo json_encode($arrCate); } break; case 'update': $catename = t($_POST['catename']); $cateid = intval($_POST['cateid']); if($userid == '0'){ echo 0;//未登录 }else if(empty($catename) || mb_strlen($catename,'utf8')>16) { echo 1;//为空或长度太长 }else{ //执行update $arrData = array('catename'=>$catename); $new['note']->update('note_cate',array( 'cateid'=>$cateid ),$arrData); //根据cateid获取分类名称 $strCate = $new['note']->getOneCate($cateid); header("Content-type: application/json", true); echo json_encode($strCate); } break; }
12ik
trunk/app/note/action/cate_ajax.php
PHP
oos
1,239
<?php defined('IN_IK') or die('Access Denied.'); //用户是否登录 $userid = aac('user')->isLogin(); switch($ts){ case "edit" : //分类 $arrCate = $new['note']->getArrCate($userid); $noteid = intval( $_GET['noteid'] ); $strNote = $db->once_fetch_assoc ( "select * from " . dbprefix . "note where noteid='$noteid'" ); $title = '编辑日志'; include template('edit'); break; case "edit_do" : $noteid = $_GET['noteid']; $cateid = $_POST['cateid']; $title = htmlspecialchars(trim($_POST['title'])); $content = $_POST['content']; if($title=='' || $content=='') qiMsg("标题和内容都不能为空!"); if(mb_strlen($title,'utf8')>64) tsNotice('标题很长很长很长很长...^_^'); if(mb_strlen($content,'utf8')>50000) tsNotice('发这么多内容干啥^_^'); $isphoto = 0; $isattach = 0; //判断是否有图片和附件 preg_match_all('/\[(photo)=(\d+)\]/is', $content, $photo); if($photo[2]){ $isphoto = '1'; } //判断附件 preg_match_all('/\[(attach)=(\d+)\]/is', $content, $attach); if($attach[2]){ $isattach = '1'; } $arrData = array( 'cateid' => $cateid, 'title' => $title, 'content' => $content, ); $new['note']->update('note',array( 'noteid'=>$noteid, ),$arrData); //处理标签 aac('tag')->addTag('note','noteid',$noteid, trim($_POST['tag']) ); header("Location: ".SITE_URL.tsUrl('note','show',array('noteid'=>$noteid))); break; case "del" : //分类 $noteid = intval( $_GET['noteid'] ); $strNote= $new['note']->find('note',array('noteid'=>$noteid)); if( $userid == $strNote['userid'] || $IK_USER['user']['isadmin'] == '1'){ //删除帖子 $new['note']->delNote($noteid); header("Location: ".SITE_URL.tsUrl('note','index',array('ts'=>'user','userid'=>$userid))); }else{ tsNotice('没有日志可以删除,别瞎搞!'); } break; //case "" : }
12ik
trunk/app/note/action/do.php
PHP
oos
2,029
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); $noteid = intval ( $_GET ['noteid'] ); //根据noteid获取内容 $strNote = aac('note')-> getOneNote($noteid); $strNote['tags'] = aac('tag')->getObjTagByObjid('note','noteid',$noteid); //标签 $strNote ['content'] = editor2html ( $strNote ['content'] ); $strNote ['user'] = aac ( 'user' )->getOneUser ( $strNote ['userid'] ); //获取评论 $page = isset ( $_GET ['page'] ) ? intval ( $_GET ['page'] ) : 1; $url = SITE_URL . tsUrl ( 'note', 'show', array ('noteid' => $noteid, 'page' => '' ) ); $lstart = $page * 10 - 10; $arrComments = $db->fetch_all_assoc("select * from ".dbprefix."note_comment where `noteid`='$noteid' order by addtime desc limit $lstart,10"); foreach ( $arrComments as $key => $item ) { $arrComment [] = $item; $arrComment [$key] ['user'] = aac ( 'user' )->getOneUser ( $item ['userid'] ); $arrComment [$key] ['recomment'] = $new['note']->getRecomment($item['referid']); } //获取评论数量 $commentNum = aac('note')->getCommnetnum($noteid); $pageUrl = pagination ( $commentNum, 10, $page, $url ); if ($page > 1) { $title = $strNote ['title'] . ' - 第' . $page . '页 - ' . $strNote ['cate'] ['catename']; } else { $title = $strNote ['title'] . ' - ' . $strNote ['cate'] ['catename']; } //更新统计 被浏览数 $userid = intval($_SESSION['tsuser']['userid']); //回话userid if($userid != $strNote['userid']){ $arrData = array('count_view'=> $strNote['count_view']+1); $new['note']->update('note',array('noteid'=>$noteid),$arrData); } include template ( 'show' );
12ik
trunk/app/note/action/show.php
PHP
oos
1,608
<?php defined('IN_IK') or die('Access Denied.'); //管理入口 if(is_file('app/'.$app.'/action/admin/'.$mg.'.php')){ include_once 'app/'.$app.'/action/admin/'.$mg.'.php'; }else{ qiMsg('sorry:no index!'); }
12ik
trunk/app/note/action/admin.php
PHP
oos
219
<?php //帖子标签 defined('IN_IK') or die('Access Denied.'); $tagname = urldecode(trim($_GET['tagname'])); $tagid = aac('tag')->getTagId(t($tagname)); $strTag = $db->once_fetch_assoc("select * from ".dbprefix."tag where tagid='$tagid'"); $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $url = SITE_URL.tsUrl('note','note_tag',array('tagid'=>$tagid,'page'=>'')); $lstart = $page*30-30; $arrTagId = $db->fetch_all_assoc("select * from ".dbprefix."tag_note_index where tagid='$tagid' limit $lstart,30"); $note_num = $db->once_fetch_assoc("select count(noteid) from ".dbprefix."tag_note_index where tagid='$tagid'"); $pageUrl = pagination($note_num['count(noteid)'], 30, $page, $url); foreach($arrTagId as $item){ $strNote = $db->once_fetch_assoc("select * from ".dbprefix."note where noteid = '".$item['noteid']."'"); $arrNotes[] = $strNote; } foreach($arrNotes as $key=>$item){ $arrNote[] = $item; $arrNote[$key]['content'] = getsubstrutf8(t($item['content']),0,50); $arrNote[$key]['user'] = aac('user')->getOneUser($item['userid']); } //热门tag $arrTag = $db->fetch_all_assoc("select * from ".dbprefix."tag order by count_note desc limit 10"); $title = $strTag['tagname'].'列表'; include template("note_tag");
12ik
trunk/app/note/action/note_tag.php
PHP
oos
1,287
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); $userid = intval ( $_GET ['userid'] ); //获取用户信息 $strUser = aac('user')->getOneUser($userid); if($userid == 0) header("Location: ".SITE_URL."index.php"); //分页 $page = isset($_GET['page']) ? $_GET['page'] : '1'; $url = SITE_URL."index.php?app=note&ac=index&ts=user&userid=".$userid."&page="; $lstart = $page*10-10; $arrNotes = $db->fetch_all_assoc ( "select * from " . dbprefix . "note where `userid`='$userid' order by addtime desc limit $lstart, 10" ); foreach($arrNotes as $key=>$item){ $arrNote[] = $item; $arrNote[$key]['photo'] = $new['note']->getOnePhoto($item['content']); $arrNote[$key]['content'] = getsubstrutf8(t($item['content']),0,200); $arrNote[$key]['user'] = aac('user')->getOneUser($item['userid']); $arrNote[$key]['cate'] = $new['note']->getOneCate($item['cateid']); } $noteNum = $db->once_num_rows("select * from ".dbprefix."note where `userid`='$userid' "); $pageUrl = pagination($noteNum, 10, $page, $url); //我的日志分类 $arrCate = aac('note')->getArrCate($userid); if($IK_USER['user']['userid'] == $userid){ $title = '我的日志'; $userCateName = '我的日志分类'; }else{ $title = $strUser['username'].'的日志'; $userCateName = $strUser['username'].'的日志分类'; } include template ( 'list' );
12ik
trunk/app/note/action/list.php
PHP
oos
1,446
<?php defined('IN_IK') or die('Access Denied.'); switch($ts){ case "list"; $cateid = intval($_GET['cateid']); //列表 $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $url = SITE_URL.tsUrl('note','cate',array('cateid'=>$cateid,'page'=>'')); $lstart = $page*10-10; $arrNotes = $db->fetch_all_assoc("select * from ".dbprefix."note where `cateid`='$cateid' and `isaudit`='0' order by addtime desc limit $lstart, 10"); $articleNum = $db->once_fetch_assoc("select count(*) from ".dbprefix."note where `cateid`='$cateid'"); $pageUrl = pagination($articleNum['count(*)'], 10, $page, $url); foreach($arrNotes as $key=>$item){ $arrNote[] = $item; $arrNote[$key]['photo'] = $new['note']->getOnePhoto($item['content']); $arrNote[$key]['content'] = getsubstrutf8(t($item['content']),0,200); $arrNote[$key]['user'] = aac('user')->getOneUser($item['userid']); } //根据用户获取文章分类 $strCate = $new['note']->getOneCate($cateid); $userid = $strCate['userid']; $arrCate = $new['note']->getArrCate($userid); $title = $strCate['catename']; include template('cate_list'); break; case "edit"; $userid = aac('user')->isLogin(); //根据用户获取文章分类 $arrCate = $new['note']->getArrCate($userid); $title = "分类管理"; include template('edit_cate'); break; }
12ik
trunk/app/note/action/cate.php
PHP
oos
1,381
<?php defined('IN_IK') or die('Access Denied.'); //不登陆不允许评论 $userid = aac('user')->isLogin(); switch($ts){ //添加评论 case "add": $noteid = intval($_POST['noteid']); $content = trim($_POST['content']); if($content == '') tsNotice('没有任何内容是不允许你通过滴^_^'); if(mb_strlen($content,'utf8')>10000) tsNotice('发这么多内容干啥,最多只能写1000千个字^_^,回去重写哇!'); //正确之后执行 $arrData = array( 'noteid' => $noteid, 'userid' => $userid, 'content' => htmlspecialchars($content), 'addtime' => time() ); //添加评论 $commentid = $new['note'] -> create('note_comment', $arrData); //统计评论数 $count_comment = $db->once_num_rows("select * from ".dbprefix."note_comment where noteid='$noteid'"); //更新评论数 $db->query("update ".dbprefix."note set count_comment='$count_comment' where noteid='$noteid'"); header("Location: ".SITE_URL.tsUrl('note','show', array('noteid'=>$noteid))); break; //删除评论 case "delete": $commentid = intval($_GET['commentid']); $strComment = $new['note']->find('note_comment',array( 'commentid'=>$commentid, )); //根据回复id查找note $strNote = $new['note']->find('note',array( 'noteid'=>$strComment['noteid'], )); //判断用户是有权限删除 if($strNote['userid'] == $userid || $IK_USER['user']['isadmin']==1){ $new['note']->delComment($commentid); //更新统计 $db->query("update ".dbprefix."note set count_comment=count_comment-1 where noteid='".$strComment['noteid']."'"); } //跳转 header("Location: ".SITE_URL.tsUrl('note','show',array('noteid'=>$strComment['noteid']))); break; //回复评论 case "recomment": $referid = intval($_POST['referid']); $noteid = $_POST['noteid']; $content = trim($_POST['content']); $addtime = time(); //安全性检查 if( mb_strlen($content, 'utf8') > 10000) { echo 1; exit (); } //正确之后执行 $arrData = array( 'noteid' => $noteid, 'referid' => $referid, 'userid' => $userid, 'content' => htmlspecialchars($content), 'addtime' => time() ); //添加评论 $commentid = $new['note'] -> create('note_comment', $arrData); //统计评论数 $count_comment = $db->once_num_rows("select * from ".dbprefix."note_comment where noteid='$noteid'"); //更新评论数 $db->query("update ".dbprefix."note set count_comment='$count_comment' where noteid='$noteid'"); echo 0; break; }
12ik
trunk/app/note/action/comment.php
PHP
oos
2,634
{template header} <div class="midder"> <div class="mc"> <h1>{$tiele}</h1> <form method="POST" action="{SITE_URL}index.php?app=note&ac=do&ts=edit_do&noteid={$strNote[noteid]}"> <table cellspacing="0" cellpadding="0" class="table_1"> <tr><th>分类:</th><td> <select name="cateid" class="txt" id="cate_select" style="float:left;"> <!--{if $arrCate==''}--> <option selected="select" value="0">默认分类</option> <!--{else}--> <!--{loop $arrCate $key $item}--> <option {if $item[cateid]==$strNote[cateid]} selected="select" {/if} value="{$item[cateid]}" >{$item[catename]}</option> <!--{/loop}--> <!--{/if}--> </select> <span id="cate_input" style="display:none; float:left; margin-left:5px; margin-top:2px"> <input type="text" class="txt" style="width:100px;float:left; display:inline-block" name="catename"/> <input class="subab" type="button" value="新增" onClick="cateOptions.addPost();" style="float:left; display:inline-block; margin-left:5px; margin-top:2px" /> <a href="javascript:;" onClick="cateOptions.cancel();" style="float:left; display:inline-block; margin-left:5px; margin-top:2px" >取消</a> </span> <span id="new_cate" style="float:left; margin-left:5px; margin-top:2px"> <a href="javascript:;" onClick="cateOptions.createCateName()">+新建分类</a> </span> </td></tr> <tr><th>题目:</th><td><input style="width:400px;" name="title" class="txt" value="{$strNote[title]}"/></td></tr> <tr><th>内容:</th><td><textarea style="width:600px;height:300px;" id="editor_mini" name="content">{$strNote[content]}</textarea></td></tr> <tr><th>标签:</th><td><input style="width:400px;" name="tag" class="txt"/> <span class="tip">(多个标签请用空格分开)</span></td></tr> <tr><th></th><td><input class="submit" type="submit" value="编辑好了,发布" /></td></tr> </table> </form> </div> </div> <!--加载编辑器--> <script src="{SITE_URL}public/js/editor/xheditor/xheditor.js" type="text/javascript"></script> <script src="{SITE_URL}public/js/editor/xheditor/loadeditor.js" type="text/javascript"></script> {template footer}
12ik
trunk/app/note/html/edit.html
HTML
oos
2,112
{template header} <!--main--> <div class="midder"> <div class="mc"> {template edit_xbar} <div class="cleft"> <table align="center" style="width:100%;clear: both;" class="table_1"> <!--{loop $arrCate $key $item}--> <tr id="info_$item[cateid]"> <td width="27%"><span id="catename_$item[cateid]">{$item[catename]}</span><input type="text" value="{$item[catename]}" name="catename" class="txt" style="display:none"/></td> <td width="73%"> <span> <a href="javascript:;" onClick="cateOptions.edit(this,'$item[cateid]')" >编辑</a> </span> <span style="display:none"> <button onClick="cateOptions.update(this,'$item[cateid]')" class="subab">保存</button> <a href="javascript:;" onClick="cateOptions.cancel_edit(this,'$item[cateid]')" >取消</a> </span> </td> </tr> <!--{/loop}--> </table> </div> <div class="cright"> <p class="pl2"><a href="{SITE_URL}{tsUrl('note','list',array('userid'=>$userid))}">&gt; 返回到我的日志</a></p> </div> </div> </div> <!--加载编辑器--> {template footer}
12ik
trunk/app/note/html/edit_cate.html
HTML
oos
1,143
{template header} <div class="midder"> <div class="mc"> <h1>写日志</h1> <form method="POST" action="{SITE_URL}index.php?app=note&ac=add&ts=do"> <table cellspacing="0" cellpadding="0" class="table_1"> <tr><th>分类:</th><td> <select name="cateid" class="txt" id="cate_select" style="float:left;"> <!--{if $arrCate==''}--> <option selected="select" value="0">默认分类</option> <!--{else}--> <!--{loop $arrCate $key $item}--> <option {if $item[cateid] == $cateid } selected="select" {/if} value="{$item[cateid]}" >{$item[catename]}</option> <!--{/loop}--> <!--{/if}--> </select> <span id="cate_input" style="display:none; float:left; margin-left:5px; margin-top:2px"> <input type="text" class="txt" style="width:100px;float:left; display:inline-block" name="catename"/> <input class="subab" type="button" value="新增" onClick="cateOptions.addPost();" style="float:left; display:inline-block; margin-left:5px; margin-top:2px" /> <a href="javascript:;" onClick="cateOptions.cancel();" style="float:left; display:inline-block; margin-left:5px; margin-top:2px" >取消</a> </span> <span id="new_cate" style="float:left; margin-left:5px; margin-top:2px"> <a href="javascript:;" onClick="cateOptions.createCateName()">+新建分类</a> </span> </td></tr> <tr><th>题目:</th><td><input style="width:400px;" name="title" class="txt"/></td></tr> <tr><th>内容:</th><td><textarea style="width:600px;height:300px;" id="editor_mini" name="content"></textarea></td></tr> <tr><th>标签:</th><td><input style="width:400px;" name="tag" class="txt"/> <span class="tip">(多个标签请用空格分开)</span></td></tr> <tr><th></th><td><input class="submit" type="submit" value="发布日志" /></td></tr> </table> </form> </div> </div> <!--加载编辑器--> <script src="{SITE_URL}public/js/editor/xheditor/xheditor.js" type="text/javascript"></script> <script src="{SITE_URL}public/js/editor/xheditor/loadeditor.js" type="text/javascript"></script> {template footer}
12ik
trunk/app/note/html/add.html
HTML
oos
2,027
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <div class="page">{$pageUrl}</div> <table> <tr class="old"> <td>日志ID</td><td>日志名称</td><td>日志分类</td><td>操作</td> </tr> <!--{loop $arrNote $key $item}--> <tr><td>{$item[noteid]}</td><td>{$item[title]}</td><td>{$item[catename]}</td> <td><a href="{SITE_URL}index.php?app=note&ac=admin&mg=note&ts=edit&noteid={$item[noteid]}">修改</a></td></tr> <!--{/loop}--> </table> </div> {php include template("admin/footer");}
12ik
trunk/app/note/html/admin/note_list.html
HTML
oos
577
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="160780470@qq.com" /> <meta name="Copyright" content="{$IK_SOFT[info][copyright]" /> <title></title> <link type="text/css" rel="stylesheet" href="{$IK_APP[system][skin]}default/style.css" id="skin" /> <!--公用的JS--> <script src="{SITE_URL}public/js/jquery.js" type="text/javascript"></script> <script> var siteUrl = '{SITE_URL}'; </script> <script src="{SITE_URL}app/{$app}/js/admin.js" type="text/javascript"></script> </head> <body> <!--header-->
12ik
trunk/app/note/html/admin/header.html
HTML
oos
743
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <div>暂无配置</div> </div> {php include template("admin/footer");}
12ik
trunk/app/note/html/admin/options.html
HTML
oos
185
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <div class="page">{$pageUrl}</div> <table> <tr class="old"> <td width="100">分类ID</td><td>分类名称</td> <td>操作</td> </tr> <!--{loop $arrCate $key $item}--> <tr><td>{$item[cateid]}</td><td>{$item[catename]}</td><td><a href="{SITE_URL}index.php?app=article&ac=admin&mg=cate&ts=edit&cateid={$item[cateid]}">修改</a></td></tr> <!--{/loop}--> </table> </div> {php include template("admin/footer");}
12ik
trunk/app/note/html/admin/cate_list.html
HTML
oos
525
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <form method="POST" action="{SITE_URL}index.php?app=article&ac=admin&mg=cate&ts=add_do"> <table> <tr> <td width="100">分类名称:</td><td><input name="catename" /></td> </tr> <tr><td></td><td><input type="submit" value="添加" /></td></tr> </table> </form> </div> {php include template("admin/footer");}
12ik
trunk/app/note/html/admin/cate_add.html
HTML
oos
427
<h2>配置管理</h2> <div class="tabnav"> <ul> <li {if $mg=='options'} class="select" {/if} ><a href="{SITE_URL}index.php?app=note&ac=admin&mg=options">配置</a></li> <li {if $mg=='note' && $ts=='list'} class="select" {/if} ><a href="{SITE_URL}index.php?app=note&ac=admin&mg=note&ts=list">全部日志</a></li> <li {if $mg=='cate' && $st=='list'} class="select" {/if} ><a href="{SITE_URL}index.php?app=note&ac=admin&mg=cate&ts=list">日志分类</a></li> <li {if $mg=='cate' && $st=='add'} class="select" {/if} ><a href="{SITE_URL}index.php?app=note&ac=admin&mg=cate&ts=add">添加分类</a></li> </ul> </div>
12ik
trunk/app/note/html/admin/menu.html
HTML
oos
632
<!--footer--> </body> </html>
12ik
trunk/app/note/html/admin/footer.html
HTML
oos
29
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <form method="POST" action="{SITE_URL}index.php?app=article&ac=admin&mg=cate&ts=edit_do"> <table> <tr> <td width="100">分类名称:</td><td><input name="catename" value="{$strCate[catename]}" /></td> </tr> <tr><td></td><td> <input type="hidden" name="cateid" value="{$cateid}" /> <input type="submit" value="添加" /></td></tr> </table> </form> </div> {php include template("admin/footer");}
12ik
trunk/app/note/html/admin/cate_edit.html
HTML
oos
514
{php include pubTemplate("header");}
12ik
trunk/app/note/html/header.html
HTML
oos
36
{template header} <div class="midder"> <div class="mc"> <h1>{$title}</h1> <div class="cleft"> <div class="note_list"> <!--{if $arrNote}--> <!--{loop $arrNote $key $item}--> <dl> <dt><a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}" title="{$item[title]}">{$item[title]}</a><span class="open"><a href="javascript:;">开关</a></span></dt> <dd class="addtime"><a href="{SITE_URL}{tsUrl('user','space',array('id'=>$item[user][userid]))}">{$item[user][username]}</a> 发表于 {php echo date('Y-m-d H:i:s',$item[addtime])}</dd> <dd class="note_des">{$item[content]}</dd> <dd class="action"> {$item[count_view]} 人浏览 &nbsp;&nbsp;<a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}#comments" title="回应">{$item[count_comment]} 条回应</a> <!--{if $item[userid] == $IK_USER[user][userid]}--> &gt; <a href="{SITE_URL}{tsUrl('note','do',array('ts'=>'edit', 'noteid'=>$item[noteid]))}" title="">修改</a> &gt; <a href="{SITE_URL}{tsUrl('note','do',array('ts'=>'del', 'noteid'=>$item[noteid]))}" title="">删除</a> <!--{/if}--> </dd> </dl> <!--{/loop}--> <!--{else}--> <p class="pl">你可以在这里记录您日记了,马上就 <a href="{SITE_URL}{tsUrl('note','add')}">开始</a> 写吧。</p> <!--{/if}--> </div> <div class="page">{$pageUrl}</div> </div> <div class="cright"> <!--{if $userid == $IK_USER[user][userid] }--> <p class="pl2">&gt; <a href="{SITE_URL}{tsUrl('note','add')}">写 日 志</a></p> <p class="pl2">&gt; <a href="{SITE_URL}{tsUrl('note','cate',array('ts'=>'edit'))}">日志分类管理</a></p> <!--{/if}--> <h2>{$userCateName}</h2> <div class="cate"> <ul> <!--{loop $arrCate $key $item}--> <li {if $item[cateid]==$cateid} class="select" {/if} ><a href="{SITE_URL}{tsUrl('note','cate',array('ts'=>'list','userid'=>$item[userid], 'cateid'=>$item[cateid]))}">{$item[catename]}</a></li> <!--{/loop}--> </ul> </div> </div> </div> </div> {template footer}
12ik
trunk/app/note/html/index.html
HTML
oos
2,380
{template header} <div class="midder"> <div class="mc"> <h1>{$title}</h1> <div class="cleft"> <div class="note_list"> <!--{if $arrNote}--> <!--{loop $arrNote $key $item}--> <dl> <dt><a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}" title="{$item[title]}">{$item[title]}</a><span class="open"><a href="javascript:;">开关</a></span></dt> <dd class="addtime"><a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}">{$item[user][username]}</a> 发表于 {php echo date('Y-m-d H:i:s',$item[addtime])}</dd> <dd class="note_des">{$item[content]}</dd> <dd class="action"> {$item[count_view]} 人浏览 &nbsp;&nbsp;<a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}#comments" title="回应">{$item[count_comment]} 条回应</a> <!--{if $item[userid] == $IK_USER[user][userid]}--> &gt; <a href="{SITE_URL}{tsUrl('note','do',array('ts'=>'edit', 'noteid'=>$item[noteid]))}" title="">修改</a> &gt; <a href="{SITE_URL}{tsUrl('note','do',array('ts'=>'del', 'noteid'=>$item[noteid]))}" title="">删除</a> <!--{/if}--> </dd> </dl> <!--{/loop}--> <!--{else}--> <p class="pl">你可以在这里记录您日记了,马上就 <a href="{SITE_URL}{tsUrl('note','add')}">开始</a> 写吧。</p> <!--{/if}--> </div> <div class="page">{$pageUrl}</div> </div> <div class="cright"> <!--{if $userid == $IK_USER[user][userid] }--> <p class="pl2">&gt; <a href="{SITE_URL}{tsUrl('note','add')}">写 日 志</a></p> <p class="pl2">&gt; <a href="{SITE_URL}{tsUrl('note','cate',array('ts'=>'edit'))}">日志分类管理</a></p> <!--{/if}--> <h2>{$userCateName}</h2> <div class="cate"> <ul> <!--{loop $arrCate $key $item}--> <li {if $item[cateid]==$cateid} class="select" {/if} ><a href="{SITE_URL}{tsUrl('note','cate',array('ts'=>'list', 'cateid'=>$item[cateid]))}">{$item[catename]}</a></li> <!--{/loop}--> </ul> </div> </div> </div> </div> {template footer}
12ik
trunk/app/note/html/list.html
HTML
oos
2,349
{template header} <div class="midder"> <div class="mc"> <h1>{$strCate[catename]}</h1> <div class="cleft"> <div class="note_list"> <!--{loop $arrNote $key $item}--> <dl> <dt><a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}" title="{$item[title]}">{$item[title]}</a><span class="open"><a href="javascript:;">开关</a></span></dt> <dd class="addtime"><a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}">{$item[user][username]}</a> 发表于 {php echo date('Y-m-d H:i:s',$item[addtime])}</dd> <dd class="note_des">{$item[content]}</dd> <dd class="action"> {$item[count_view]} 人浏览 &nbsp;&nbsp;<a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}#comments" title="回应">{$item[count_comment]} 条回应</a> <!--{if $item[userid] == $IK_USER[user][userid]}--> &gt; <a href="{SITE_URL}{tsUrl('note','do',array('ts'=>'edit', 'noteid'=>$item[noteid]))}" title="">修改</a> &gt; <a href="{SITE_URL}{tsUrl('note','do',array('ts'=>'del', 'noteid'=>$item[noteid]))}" title="">删除</a> <!--{/if}--> </dd> </dl> <!--{/loop}--> </div> <div class="page">{$pageUrl}</div> </div> <div class="cright"> <!--{if $userid == $IK_USER[user][userid] }--> <p class="pl2">&gt; <a href="{SITE_URL}{tsUrl('note','add')}">写 日 志</a></p> <!--{/if}--> <h2> 日志分类 &nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;· <span class="pl">&nbsp;(<a href="{SITE_URL}{tsUrl('note','list',array(userid=>$userid))}">全部</a>) </span> </h2> <div class="cate"> <ul> <!--{loop $arrCate $key $item}--> <li {if $item[cateid]==$cateid} class="select" {/if} ><a href="{SITE_URL}{tsUrl('note','cate',array('ts'=>'list', 'cateid'=>$item[cateid]))}">{$item[catename]}</a></li> <!--{/loop}--> </ul> </div> </div> </div> </div> {template footer}
12ik
trunk/app/note/html/cate_list.html
HTML
oos
2,162
<h1>{$title}</h1> <div class="tabnav"> <ul> <li <!--{if $ts=="edit"}-->class="select"<!--{/if}-->><a href="{SITE_URL}{tsUrl('note','cate',array('ts'=>'edit'))}">全部分类</a></li> </ul> </div>
12ik
trunk/app/note/html/edit_xbar.html
HTML
oos
200
{template header} <div class="midder"> <div class="mc"> <h1> <a href="{SITE_URL}{tsUrl('note','note_tag',array(tagname=>$tagname))}">{$strTag[tagname]}</a> </h1> <div class="cleft"> <div class="tag_list"> <!--{if $arrNote}--> <!--{loop $arrNote $key $item}--> <div class="result"> <div class="pic"> <a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}" class="nbg"> <img alt="{$item[user][username]}" src="{$item[user][face]}"></a> </div> <div class="content"> <h3><a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}">{$item[title]}</a></h3> <div class="info">发表于 {php echo date('Y-m-d',$item[addtime])} &nbsp; <a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}">阅读 {$item[count_view]} 次</a> &nbsp;&nbsp;<a href="{SITE_URL}{tsUrl('note','show',array('noteid'=>$item[noteid]))}#comments" title="回应"> {$item[count_comment]} 条回应</a></div> <p>{$item[content]}</p> </div> </div> <!--{/loop}--> <!--{/if}--> </div> <div class="page">{$pageUrl}</div> <div class="clear"></div> </div> <div class="cright"> <div class="tags"> <h2>热门标签</h2> <ul> <!--{loop $arrTag $key $item}--> <li><a class="post-tag" href="{SITE_URL}{tsUrl('note','note_tag',array(tagname=>$item[tagname]))}">{$item[tagname]}</a>×{$item[count_note]}</li> <!--{/loop}--> </ul> </div> </div> </div> </div> {template footer}
12ik
trunk/app/note/html/note_tag.html
HTML
oos
1,893
{php include pubTemplate("footer");}
12ik
trunk/app/note/html/footer.html
HTML
oos
36
{template header} <div class="midder"> <div class="mc"> <div class="cleft"> <div class="art-body"> <h1 class="title">{$strNote[title]}</h1> <div style="text-align:center;color:#999999;padding-bottom: 10px;border-bottom: 1px solid #DDDDDD; margin-bottom:10px"><a href="{SITE_URL}{tsUrl('hi','',array('id'=>$strNote[user][doname]))}">{$strNote[user][username]}</a> 发表于 {php echo date('Y-m-d H:i:s',$strNote[addtime])} <a href="#comments">{$strNote[count_comment]}条回复</a> 浏览{$strNote[count_view]}次 <a href="#formMini">我要回复</a> </div> <div class="art-text"> {$strNote[content]} </div> <div class="options-bar"> <!--{if intval($IK_USER[user][userid])==$strNote[userid]}--> &gt;&nbsp; <a href="{SITE_URL}index.php?app=note&ac=do&ts=edit&noteid={$strNote[noteid]}">修改</a> &gt;&nbsp; <a href="{SITE_URL}index.php?app=note&ac=do&ts=del&noteid={$strNote[noteid]}">删除</a> <!--{/if}--> </div> <div class="clear"></div> </div> <!--tag标签--> <div class="tags"> <!--{loop $strNote[tags] $key $item}--> <a rel="tag" title="" class="post-tag" href="{SITE_URL}{tsUrl('note','note_tag',array(tagname=>$item[tagname]))}">{$item[tagname]}</a> <!--{/loop}--> <!--{if intval($IK_USER[user][userid])==$strNote[userid]}--> <a rel="tag" href="javascript:void(0);" onclick="showTagFrom()">+标签</a> <p id="tagFrom" style="display:none"> <input class="tagtxt" type="text" name="tags" id="tags" /> <button type="submit" class="subab" onclick="savaTag({$noteid})">添加</button> <a href="javascript:void(0);" onclick="showTagFrom()">取消</a> </p> <!--{/if}--> </div> <!--comment评论--> <ul class="comment"> <!--{if is_array($arrComment)}--> <!--{loop $arrComment $key $item}--> <li class="clearfix"> <div class="user-face"> <a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}"><img title="{$item[user][username]}" alt="{$item[user][username]}" src="{$item[user][face]}"></a> </div> <div class="reply-doc"> <h4>{php echo date('Y-m-d H:i:s',$item[addtime])} <a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}">{$item[user][username]}</a> </h4> <!--{if $item[referid] !='0'}--> <div class="recomment"><a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[recomment][user][doname]))}"><img src="{$item[recomment][user][face]}" width="24" align="absmiddle"></a> <strong><a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[recomment][user][doname]))}">{$item[recomment][user][username]}</a></strong>:{php echo nl2br($item[recomment][content])}</div> <!--{/if}--> <p> {php echo nl2br($item[content])} </p> <!--签名--> <!--{if $item[user][signed] != ''}--> <div class="signed">{$item[user][signed]}</div> <!--{/if}--> <div class="group_banned"> <!--{if $IK_USER[user][userid] == $item[userid] || $IK_USER[user][isadmin]==1}--> <span> <a href="javascript:void(0)" onclick="commentOpen({$item[commentid]},{$item[noteid]})">回复</a> </span> <span> <a class="j a_confirm_link" href="{SITE_URL}index.php?app=note&ac=comment&ts=delete&commentid={$item[commentid]}" rel="nofollow" onclick="return confirm('确定删除?')">删除</a> </span> <!--{/if}--> </div> <div id="rcomment_{$item[commentid]}" style="display:none; clear:both; padding:0px 10px"> <textarea style="width:550px;height:50px;font-size:12px; margin:0px auto;" id="recontent_{$item[commentid]}" type="text" onkeydown="keyRecomment({$item[commentid]},{$item[noteid]},event)" class="txt"></textarea> <p style=" padding:5px 0px"><button onclick="recomment({$item[commentid]},{$item[noteid]})" id="recomm_btn_$item[commentid]" class="subab">提交</button>&nbsp;&nbsp;<a href="javascript:;" onclick="$('#rcomment_{$item[commentid]}').slideToggle('fast');">取消</a> </p> </div> </div> <div class="clear"></div> </li> <!--{/loop}--> <!--{/if}--> </ul> <div class="page">{$pageUrl}</div> <h2>你的回应&nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·</h2> <div id="comments"> <!--{if intval($IK_USER[user][userid])==0}--> <div style="border:solid 1px #DDDDDD; text-align:center;padding:20px 0"><a href="{SITE_URL}{tsUrl('user','login')}">登录</a> | <a href="{SITE_URL}{tsUrl('user','register')}">注册</a></div> <!--{else}--> <form method="POST" action="{SITE_URL}index.php?app=note&ac=comment&ts=add" onSubmit="return checkComment('#formMini');" id="formMini"> <textarea style="width:100%;height:100px;" id="editor_mini" name="content" class="txt" onkeydown="keyComment('#formMini',event)"></textarea> <input type="hidden" name="noteid" value="{$strNote[noteid]}" /> <input class="submit" type="submit" value="加上去(Crtl+Enter)" style="margin:10px 0px"> </form> <!--{/if}--> </div> </div> <div class="cright"> <!--{if $strNote[user][userid] == $IK_USER[user][userid] }--> <p class="pl2"><a href="{SITE_URL}{tsUrl('note','list',array('userid'=>$strNote[user][userid]))}">&gt; 返回到我的日志</a></p> <!--{else}--> <p class="pl2"><a href="{SITE_URL}{tsUrl('note','list',array('userid'=>$strNote[user][userid]))}">&gt; 返回到$strNote[user][username]的日志</a></p> <!--{/if}--> </div> </div> </div> {template footer}
12ik
trunk/app/note/html/show.html
HTML
oos
5,333
<?php defined('IN_IK') or die('Access Denied.'); return array( 'name' => '日志', 'version' => '1.0', 'desc' => '日志,博客,文章', 'url' => 'http://www.12ik.com', 'email' => '160780470@qq.com', 'author' => '小麦', 'author_url' => 'http://www.12ik.com', 'isoption' => '1', 'isinstall' => '1' );
12ik
trunk/app/note/about.php
PHP
oos
326
.note_list{} .note_list dl{ margin:10px 0px 20px 0px} .note_list dl dt{ background-color:#eeffee; line-height:25px; display:block; clear:both; font-size:14px} .note_list dl dt span{ float:right; margin-right:10px; padding-top:2px} .open a, .close a{ background-image:url(arrow.png); background-repeat:no-repeat} .note_list dl dt .open a{ display:inline-block; height:15px; width:30px; text-align:center; line-height:15px; overflow:hidden; background-position:center 3px; text-indent:-999px} .note_list dl dt .open a:hover{ background-color:#fff; border-radius:3px;} .note_list dl dt .close a{ display:inline-block; height:15px; width:30px; text-align:center; line-height:15px; overflow:hidden; background-position:center -13px; text-indent:-999px} .note_list dl dt .close a:hover{ background-color:#fff; border-radius:3px;} .note_list dd,.note_list dt{ display:block; clear:both; padding:0px 5px;} .note_list dd.addtime{ color:#666666; margin:5px 0px;} .note_list dd.note_des{ color:#000; word-wrap: break-word; white-space: pre-wrap; font-size:14px;} .note_list dd.action{ margin-top:5px; color:#777; display:none; text-align:right} .art-body{} .art-text{font-size:14px;line-height:25px; margin-bottom:10px} .options-bar{ text-align:right; line-height:30px;} /*comment评论列表*/ .comment{width: 100%;overflow:hidden;} .comment li {margin: 0 0 0px 0px;overflow:hidden; display:block;} .comment li .user-face {float: left;height: 48px;overflow: hidden;width: 48px; margin-top:0px;} .comment li .reply-doc {float: right;width: 570px;overflow: hidden;} .comment li .reply-doc p img{max-width:450px;} .comment li .reply-doc h4 {font-weight:normal;font-size:12px;height: 22px;line-height: 22px;margin: 0 0 5px 0px;color: #666666;display: block;overflow: hidden; background-color:#F8F8F8; padding:0px 10px} .comment li .reply-doc p {margin: 0 0 25px;overflow: hidden;word-wrap: break-word;line-height:23px; padding:0px 10px} .comment li .reply-doc .recomment {background: #F8F8F8;border: 1px dashed #DDDDDD;color: #666666;font-size: 12px;padding: 10px;} .comment li .group_banned {text-align: right;} /*签名显示*/ .signed { background: url("sigline.gif") no-repeat scroll 0 0 transparent; line-height: 1.6em; overflow: hidden; padding: 20px 0 10px; margin-top:10px; color:#999999; } /**taglist**/ .result { border-bottom: 1px dashed #CCCCCC; margin-bottom: 20px; padding-bottom: 10px; position: relative; width: 100%; } .result:after { clear: both; content: " "; display: block; } .result .pic { float: left; } .result .content { display: table-cell; padding-left: 20px; } .result .content h3 { background: none repeat scroll 0 0 transparent; float: left; height: auto; margin: 0 0 5px; } .result .info { color: #999999; position: absolute; right: 10px; } .result .content p { clear: both; color: #666666; margin: 0 0 5px; }
12ik
trunk/app/note/skins/default/style.css
CSS
oos
3,004
<?php defined('IN_IK') or die('Access Denied.'); /* *包含数据库配置文件 */ require_once IKDATA."/config.inc.php"; $skin = 'default'; $IK_APP['options']['appname'] = '日志';
12ik
trunk/app/note/config.php
PHP
oos
203
<?php defined('IN_IK') or die('Access Denied.'); class note extends IKApp{ //构造函数 public function __construct($db){ parent::__construct($db); } //根据userid获取所有分类 function getArrCate($userid){ $arrCate = $this->db->fetch_all_assoc("select * from ".dbprefix."note_cate where `userid`='$userid'"); return $arrCate; } //获取一个分类 function getOneCate($cateid){ $strCate = $this->db->once_fetch_assoc("select * from ".dbprefix."note_cate where `cateid`='$cateid'"); return $strCate; } //获取文章的第一张图片 function getOnePhoto($content) { preg_match_all('/\[(photo)=(\d+)\]/is', $content, $photo); $photoid = $photo[2][0]; $strPhoto = aac('photo')->getSamplePhoto($photoid); return $strPhoto; } //根据noteid 获取日志 function getOneNote($noteid) { $strNote = $this->find('note',array('noteid'=>$noteid)); return $strNote; } //根据noteid获取评论数量 function getCommnetnum($noteid) { $num = $this->findCount("note_comment",array('noteid'=>$noteid)); return $num; } //删除评论 public function delComment($commentid){ $this->delete('note_comment',array( 'commentid'=>$commentid, )); return true; } //根据referid 获取回复评论 function getRecomment($referid){ $strComment = $this->find('note_comment',array('commentid'=>$referid)); $strComment['user'] = aac('user')->getOneUser($strComment['userid']); $strComment['content'] = editor2html($strComment['content']); return $strComment; } //删除日志 function delNote($noteid){ $this->delete('note',array('noteid'=>$noteid));//删除日志 $this->delete('note_comment',array('noteid'=>$noteid));//删评论 //$this->delete('tag_note_index',array('noteid'=>$noteid)); //删除tag标签 return true; } //获取最新日志 function getNewNote($num){ $arrNewNotes = $this->db->fetch_all_assoc("select noteid from ".dbprefix."note where isaudit='0' order by addtime desc limit $num"); if(is_array($arrNewNotes)){ foreach($arrNewNotes as $item){ $arrNewNote[] = $this->getOneNote($item['noteid']); } } return $arrNewNote; } }
12ik
trunk/app/note/class.note.php
PHP
oos
2,246
function tips(c){ $.dialog({content: '<font style="font-size:14px;">'+c+'</font>',fixed: true, width:300, time:1500}); } function succ(c){ $.dialog({icon: 'succeed',content: '<font style="font-size:14px;">'+c+'</font>' , time:2000});} function error(c){$.dialog({icon: 'error',content: '<font style="font-size:14px;">'+c+'</font>' , time:2000});} var cateOptions = { createCateName : function() { $('#cate_input').show(); $('#new_cate').hide(); }, cancel : function(){ $('#cate_input').hide(); $('#cate_input :input[name=catename]').val(''); $('#new_cate').show(); }, addPost : function() { var url = siteUrl+'index.php?app=note&ac=cate_ajax&ts=add'; var catename = $('#cate_input :input[name=catename]').val(); $.post(url,{catename: catename},function(rs){ if(rs==0) { $.dialog.open(siteUrl+'index.php?app=user&ac=ajax&ts=login', {title: '登录'}); }else if(rs == 1){ error('分类名称不能为空^_^'); }else{ var options=''; for(var i=0; i<rs.length; i++) { if(i == rs.length-1) { options += '<option value="'+rs[i]['cateid']+'" selected="selected">'+rs[i]['catename']+'</option>'; }else { options += '<option value="'+rs[i]['cateid']+'">'+rs[i]['catename']+'</option>'; } } $('#cate_select').html(options); cateOptions.cancel(); succ('新增加分类成功^_^'); } }) }, //编辑分类 edit : function(obj,cateid) { $('#info_'+cateid).find('#catename_'+cateid).hide(); $('#info_'+cateid).find('input').show(); $('#info_'+cateid).find('#option_'+cateid).show(); $(obj).parent('span').hide().siblings('span').show(); }, cancel_edit: function(obj,cateid) { $('#info_'+cateid).find('#catename_'+cateid).show(); $('#info_'+cateid).find('input').hide(); $('#info_'+cateid).find('#option_'+cateid).hide(); $(obj).parent('span').hide().siblings('span').show(); }, update: function(obj,cateid) { var url = siteUrl+'index.php?app=note&ac=cate_ajax&ts=update'; var catename = $('#info_'+cateid).find('input[name=catename]').val(); if(catename=='') {tips("分类名称不能为空");return false;} if(catename.length>15){ tips("分类名称太长了;不能超过15个字");return false;} $.post(url,{catename:catename, cateid:cateid},function(rs){ if(rs==0) { $.dialog.open(siteUrl+'index.php?app=user&ac=ajax&ts=login', {title: '登录'}); }else if(rs==1) { tips("分类名不能为空,且长度不能超过15个字"); }else{ $('#info_'+cateid).find('input[name=catename]').val(rs['catename']).hide(); $('#info_'+cateid).find('#catename_'+cateid).text(rs['catename']).show(); $(obj).parent('span').hide().siblings('span').show(); } }); } }; /*显示隐藏回复*/ function commentOpen(id,gid) { $('#rcomment_'+id).slideToggle('fast'); } //Ctrl+Enter 回应 function keyComment(obj,event) { if(event.ctrlKey == true) { if(event.keyCode == 13) if(checkComment(obj)) { $(obj).submit(); } return false; } } //安全性检测 回应帖子 function checkComment(obj) { if($(obj).find('textarea[name=content]').val() == ''){ error('你回应的内容不能为空'); return false;} if($(obj).find('textarea[name=content]').val().length > 2000){ error('你已经输入了<font color="red">'+$(obj).find('textarea[name=content]').val().length+'</font>个字;你回应的内容不能超过<font color="red">2000</font>个字。');return false;} $(obj).find('input[type=submit]').val('正在提交^_^').attr('disabled',true); return true; } //Ctrl+Enter 回复评论 function keyRecomment(rid,tid,event) { if(event.ctrlKey == true) { if(event.keyCode == 13) recomment(rid,tid); return false; } } //回复评论 function recomment(rid,tid){ c = $('#recontent_'+rid).val(); if(c==''){tips('回复内容不能为空');return false;} var url = siteUrl+'index.php?app=note&ac=comment&ts=recomment'; $('#recomm_btn_'+rid).hide(); $.post(url,{referid:rid,noteid:tid,content:c} ,function(rs){ if(rs == 0) { succ('回复成功'); window.location.reload(); }else if( rs == 1){ tips('回复内容写这么多干啥,删除点吧老大^_^') $('#recomm_btn_'+rid).show(); } }) } //日志首页 伸缩效果 $(function(){ $('.note_list dt span').bind('click',function(){ $(this).toggleClass('close'); $(this).parent().parent().find('.action').slideToggle('fast'); }); }); /*显示标签界面*/ function showTagFrom(){ $('#tagFrom').toggle('fast');} /*提交标签*/ function savaTag(tid) { var tag = $('#tags').val(); if(tag ==''){ tips('请输入标签哟^_^');$('#tagFrom').show('fast');}else{ var url = siteUrl+'index.php?app=tag&ac=add_ajax&ts=do'; $.post(url,{objname:'note',idname:'noteid',tags:tag,objid:tid},function(rs){ window.location.reload() }) } }
12ik
trunk/app/note/js/extend.func.js
JavaScript
oos
5,161
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); /* * 12IK爱客网 APP单入口 * @copyright (c) 2012-3000 12IK All Rights Reserved * @author wanglijun * @Email:160780470@qq.com */ //判断升级 if (is_file ( 'data/up.php' )) $app = 'upgrade'; if ($app == 'upgrade' && ! is_file ( 'data/up.php' )) $app = 'group'; //APP模板CSS,IMG,INC $IK_APP ['tpl'] = array ('skin' => 'app/' . $app . '/skins/', 'js' => 'app/' . $app . '/js/' ); //system系统管理模板CSS,IMG $IK_APP ['system'] = array ('skin' => 'app/system/skins/', 'js' => 'app/system/js/' ); //加载APP应用首页和配置文件 if (is_file ( 'app/' . $app . '/action/' . $ac . '.php' )) { //加载系统缓存文件 $IK_SITE ['base'] = fileRead ( 'data/system_options.php' ); //设置时区 date_default_timezone_set ( $IK_SITE ['base'] ['timezone'] ); //加载APP导航 $IK_SITE ['appnav'] = fileRead ( 'data/system_appnav.php' ); define ( 'SITE_URL', $IK_SITE ['base'] ['site_url'] ); //主题 $IK_theme = isset ( $_COOKIE ['ik_theme'] ) ? $_COOKIE ['ik_theme'] : ''; if ($IK_theme) { if (is_file ( 'theme/' . $IK_theme . '/preview.gif' )) { $site_theme = $IK_theme; } else { $site_theme = $IK_SITE ['base'] ['site_theme']; } } else { $site_theme = $IK_SITE ['base'] ['site_theme']; } //加载APP配置缓存文件 if ($app != 'system') { $IK_APP ['options'] = fileRead ( 'data/' . $app . '_options.php' ); if ($IK_APP ['options'] ['isenable'] == '1' && $ac != 'admin') { qiMsg ( $app . "应用关闭,请开启后访问!" ); } } //加载APP数据库操作类并建立对象 include_once 'app/'.$app.'/config.php'; include_once 'app/'.$app.'/class.'.$app.'.php'; $new[$app] = new $app($db); //控制前台ADMIN访问权限 if ($ac == 'admin' && $IK_USER ['admin'] ['isadmin'] != 1 && $app != 'system') { header ( "Location: " . SITE_URL ); exit (); } //控制后台访问权限 if ($IK_USER ['admin'] ['isadmin'] != 1 && $app == 'system' && $ac != 'login') { header ( "Location: " . SITE_URL . tsUrl ( 'system', 'login' ) ); exit (); } //控制插件设置权限 if ($IK_USER ['admin'] ['isadmin'] != 1 && $in == 'edit') { header ( "Location: " . SITE_URL . tsUrl ( 'system', 'login' ) ); exit (); } //判断用户是否上传头像 if ($IK_SITE ['base'] ['isface'] == 1 && $IK_USER ['user'] != '' && $app != 'system' && $ac != 'admin') { $faceUser = $new [$app]->find ( 'user_info', array ('userid' => intval ( $IK_USER ['user'] ['userid'] ) ) ); if ($faceUser ['face'] == '' && $ts != 'face') { header ( "Location: " . SITE_URL . tsUrl ( 'user', 'set', array ('ts' => 'face' ) ) ); } } //运行统计结束 $time_end = getmicrotime (); $runTime = $time_end - $time_start; $runTime = number_format ( $runTime, 6 ); //用户自动登录 if ($IK_USER ['user'] == '' && $_COOKIE ['ik_email'] != '' && $_COOKIE ['ik_pwd'] != '') { $loginUserNum = $new [$app]->findCount ( 'user', array ('email' => $_COOKIE ['ik_email'], 'pwd' => $_COOKIE ['ik_pwd'] ) ); if ($loginUserNum > 0) { $loginUserData = $new [$app]->find ( 'user_info', array ('email' => $_COOKIE ['ik_email'] ), 'userid,username,areaid,path,face,count_score,isadmin,uptime' ); //用户session信息 $_SESSION ['tsuser'] = $loginUserData; $IK_USER = array ('user' => $_SESSION ['tsuser'] ); //更新登录时间 $new [$app]->update ( 'user_info', array ('uptime' => time () ), array ('userid' => $loginUserData ['userid'] ) ); } } $tsHooks = array (); if ($app != 'system' && $app != 'pubs') { //加载公用插件 if (is_file ( 'data/pubs_plugins.php' )) { $public_plugins = fileRead ( 'data/pubs_plugins.php' ); if ($public_plugins && is_array ( $public_plugins )) { foreach ( $public_plugins as $item ) { if (is_file ( 'plugins/pubs/' . $item . '/' . $item . '.php' )) { include 'plugins/pubs/' . $item . '/' . $item . '.php'; } } } } //加载APP插件 if (is_file ( 'data/' . $app . '_plugins.php' )) { $active_plugins = fileRead ( 'data/' . $app . '_plugins.php' ); if ($active_plugins && is_array ( $active_plugins )) { foreach ( $active_plugins as $item ) { if (is_file ( 'plugins/' . $app . '/' . $item . '/' . $item . '.php' )) { include 'plugins/' . $app . '/' . $item . '/' . $item . '.php'; } } } } } //开始执行APP action include $app . '/action/' . $ac . '.php'; } else { header("Location: http://www.12ik.com/home/404/"); exit (); }
12ik
trunk/app/index.php
PHP
oos
4,728
<?php defined('IN_IK') or die('Access Denied.'); class feed extends IKApp{ //构造函数 public function __construct($db){ parent::__construct($db); } //添加feed public function add($userid,$template,$data){ $userid = intval($userid); /* if(is_array($arrDatas)){ foreach($arrDatas as $key=>$item){ $arrData[$key] = urlencode($item); } $arrData = json_encode($arrData); $this->create('feed',array( 'userid'=>$userid, 'template'=>$template, 'data'=>$arrData, 'addtime'=>time(), )); }*/ if(is_array($data)){ $data = serialize($data); $data = addslashes($data); $this->create('feed',array( 'userid'=>$userid, 'template'=>$template, 'data'=>$data, 'addtime'=>time(), )); } } //析构函数 public function __destruct(){ } }
12ik
trunk/app/feed/class.feed.php
PHP
oos
896
<?php defined('IN_IK') or die('Access Denied.'); //用户是否登录 $userid = aac('user')->isLogin(); $page = isset($_GET['page']) ? $_GET['page'] : '1'; $url = SITE_URL.tsUrl('feed','index',array('page'=>'')); $lstart = $page*20-20; $arrFeeds = $db->fetch_all_assoc("select * from ".dbprefix."feed where userid='$userid' order by addtime desc limit $lstart,20"); //查看我的广播 $feedNum = $db->once_fetch_assoc("select count(*) from ".dbprefix."feed where userid='$userid'"); $pageUrl = pagination($feedNum['count(*)'], 20, $page, $url); if($page > 1){ $title = '社区动态 - 第'.$page.'页'; }else{ $title = '社区动态'; } foreach($arrFeeds as $key=>$item){ $data = unserialize(stripslashes($item['data'])); if(is_array($data)){ foreach($data as $key=>$itemTmp){ $tmpkey = '{'.$key.'}'; $tmpdata[$tmpkey] = $itemTmp; } } $arrFeed[] = array( 'user' => aac('user')->getOneUser($item['userid']), 'content' => strtr($item['template'],$tmpdata), 'addtime' => $item['addtime'], ); } //print_r($arrFeed); include template('index');
12ik
trunk/app/feed/action/index.php
PHP
oos
1,121
<?php defined('IN_IK') or die('Access Denied.'); //用户是否登录 $userid = aac('user')->isLogin(); switch($ts){ //添加feed case "do": $content = trim($_POST['content']); if($content==''){ tsNotice('不要这么偷懒嘛,多少请写一点内容哦^_^'); }elseif(mb_strlen($content,'utf8')>100){//限制发表内容多长度,默认为1w tsNotice('发这么多内容干啥^_^'); }else{ //feed开始 $feed_template = '<span class="pl">说:</span><div class="quote"><span class="inq">{content}</span> <span></span></div>'; $feed_data = array( //'link' => SITE_URL.tsUrl('group','topic',array('id'=>$topicid)), //'title' => $strTopic['title'], 'content' =>getsubstrutf8(htmlspecialchars($content),0,100), ); aac('feed')->add($userid,$feed_template,$feed_data); //feed结束 header("Location: ".SITE_URL.tsUrl('feed','index')); } break; }
12ik
trunk/app/feed/action/addfeed.php
PHP
oos
975
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <form method="POST" action="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=contact_do"> <table cellpadding="0" cellspacing="0"> <tr><td>联系我们</td></tr> <tr><td><textarea style="width:600px;height:300px" name="infocontent">{$strInfo[infocontent]}</textarea></td></tr> <tr><td> <input type="hidden" name="infokey" value="contact" /> <input type="submit" value="提 交" /></td></tr> </table> </form> </div> {php include template("admin/footer");}
12ik
trunk/app/feed/html/admin/info_contact.html
HTML
oos
569
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <form method="POST" action="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=privacy_do"> <table cellpadding="0" cellspacing="0"> <tr><td>隐私声明</td></tr> <tr><td><textarea style="width:600px;height:300px" name="infocontent">{$strInfo[infocontent]}</textarea></td></tr> <tr><td> <input type="hidden" name="infokey" value="privacy" /> <input type="submit" value="提 交" /></td></tr> </table> </form> </div> {php include template("admin/footer");}
12ik
trunk/app/feed/html/admin/info_privacy.html
HTML
oos
569
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="160780470@qq.com" /> <meta name="Copyright" content="{$IK_SOFT[info][copyright]" /> <title></title> <link type="text/css" rel="stylesheet" href="{$IK_APP[system][skin]}default/style.css" id="skin" /> <!--公用的JS--> <script src="{SITE_URL}public/js/jquery.js" type="text/javascript"></script> <script> var siteUrl = '{SITE_URL}'; </script> <script src="{SITE_URL}app/{$app}/js/admin.js" type="text/javascript"></script> </head> <body> <!--header-->
12ik
trunk/app/feed/html/admin/header.html
HTML
oos
743
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <form method="POST" action="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=about_do"> <table cellpadding="0" cellspacing="0"> <tr><td>关于我们</td></tr> <tr><td><textarea style="width:600px;height:300px" name="infocontent">{$strInfo[infocontent]}</textarea></td></tr> <tr><td> <input type="hidden" name="infokey" value="about" /> <input type="submit" value="提 交" /></td></tr> </table> </form> </div> {php include template("admin/footer");}
12ik
trunk/app/feed/html/admin/info_about.html
HTML
oos
565
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} </div> {php include template("admin/footer");}
12ik
trunk/app/feed/html/admin/options.html
HTML
oos
162
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <table cellpadding="0" cellspacing="0"> <tr class="old"><td>名称</td><td>版本</td><td>作者/介绍</td><td>操作</td></tr> <!--{loop $arrPlugin $key $item}--> <tr class="odd"><td>{$item[about][name]} ({$item[name]})</td><td>{$item[about][version]}</td><td>介绍:{$item[about][desc]}<br />作者:{$item[about][author]}</td><td><!--{if in_array($item[name],$active_plugins)}--><a href="{SITE_URL}index.php?app={$app}&ac=admin&mg=plugin&ts=do&pname={$item[name]}&isused=0">停用</a><!--{else}--><a href="{SITE_URL}index.php?app={$app}&ac=admin&mg=plugin&ts=do&pname={$item[name]}&isused=1">启用</a><!--{/if}--> <!--{if $item[about][isedit]=='1' && in_array($item[name],$active_plugins)}--><a href="{SITE_URL}index.php?app={$app}&ac=plugin&plugin={$item[name]}&in=edit&ts=set">编辑</a><!--{/if}--> <a href="{SITE_URL}index.php?app={$app}&ac=admin&mg=plugin&ts=del&pname={$item[name]}">删除</a> </td></tr> <!--{/loop}--> </table> </div> {php include template("admin/footer");}
12ik
trunk/app/feed/html/admin/plugin_list.html
HTML
oos
1,108
{php include template("admin/header");} <!--main--> <div class="midder"> {php include template("admin/menu");} <form method="POST" action="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=agreement_do"> <table cellpadding="0" cellspacing="0"> <tr><td>用户协议</td></tr> <tr><td><textarea style="width:600px;height:300px" name="infocontent">{$strInfo[infocontent]}</textarea></td></tr> <tr><td> <input type="hidden" name="infokey" value="agreement" /> <input type="submit" value="提 交" /></td></tr> </table> </form> </div> {php include template("admin/footer");}
12ik
trunk/app/feed/html/admin/info_agreement.html
HTML
oos
573
<h2>首页管理</h2> <div class="tabnav"> <ul> <li <!--{if $mg=='options'}-->class="select"<!--{/if}-->><a href="{SITE_URL}index.php?app=home&ac=admin&mg=options">首页配置</a></li> <li <!--{if $mg=='info' && $ts=='about'}-->class="select"<!--{/if}-->><a href="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=about">关于我们</a></li> <li <!--{if $mg=='info' && $ts=='contact'}-->class="select"<!--{/if}-->><a href="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=contact">联系我们</a></li> <li <!--{if $mg=='info' && $ts=='agreement'}-->class="select"<!--{/if}-->><a href="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=agreement">用户条款</a></li> <li <!--{if $mg=='info' && $ts=='privacy'}-->class="select"<!--{/if}-->><a href="{SITE_URL}index.php?app=home&ac=admin&mg=info&ts=privacy">隐私声明</a></li> </ul> </div>
12ik
trunk/app/feed/html/admin/menu.html
HTML
oos
845
<!--footer--> </body> </html>
12ik
trunk/app/feed/html/admin/footer.html
HTML
oos
29
<div class="tabnav"> <ul> <li><a href="{SITE_URL}index.php?app=group&ac=admin&mg=plugin&ts=list">返回插件管理</a></li> </ul> </div>
12ik
trunk/app/feed/html/admin/plugin_menu.html
HTML
oos
137
{php include pubTemplate("header");}
12ik
trunk/app/feed/html/header.html
HTML
oos
36
{template header} <style> .mbtl { float: left; margin: 8px 7px 0 0; padding: 0; width: 55px; } .mbtr { border-bottom: 1px solid #EEEEEE; margin: 5px 0; min-height: 55px; overflow: hidden; padding: 5px 0; } .pl { color: #666666; line-height: 1.5; } .broadsmr { color: #999999; padding: 5px 24px; } .indentrec { color: #333333; line-height: 1.6em; margin-left: 24px; } .quote { background: url("http://t.douban.com/pics/quotel.gif") no-repeat scroll left 4px transparent; margin: 8px 0 0 26px; overflow: hidden; padding: 0 24px 5px 15px; width: auto; word-wrap: break-word; } .quote .inq { background: url("http://t.douban.com/pics/quoter.gif") no-repeat scroll right bottom transparent; color: #333333; display: inline-block; padding-right: 15px; } .broadimg { border: 1px solid #DDDDDD; float: right; margin-left: 14px; } .clearfix:after { clear: both; content: "."; display: block; height: 0; visibility: hidden; } .indentrec { color: #333333; line-height: 1.6em; margin-left: 24px; } .timeline-album { float: left; margin: 8px 12px 8px 0; } </style> <div class="midder"> <div class="mc"> <h1>我的广播</h1> <div class="cleft"> <div class="isay" id="db-isay"> <form action="{SITE_URL}index.php?app=feed&ac=addfeed&ts=do" method="post" > <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><textarea style="height: 45px; width:600px" class="txt" name="content"></textarea></td> </tr> <tr> <td height="50"><input type="submit" value="我要广播" class="submit"></td> </tr> </table> </form> </div> <ul> <!--{loop $arrFeed $key $item}--> <!--{if date('Y-m-d',$item[addtime]) !=date('Y-m-d',$arrFeed[$key-1][addtime])}--> <li style="margin-top:10px;border-bottom:1px solid #ddd;"><h2>{php echo date('Y-m-d h:s:m',$item[addtime])}</h2></li> <!--{/if}--> <li class="mbtl"> <!--{if $item[user][userid] !=$arrFeed[$key-1][user][userid]}--> <a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}" ><img title="{$item[user][username]}" alt="{$item[user][username]}" src="{$item[user][face]}"></a> <!--{/if}--> </li> <li class="mbtr"> <a href="{SITE_URL}{tsUrl('hi','',array('id'=>$item[user][doname]))}">{$item[user][username]}</a> {$item[content]} </li> <div class="clear"></div> <!--{/loop}--> </ul> <div class="clear"></div> <div class="page">{$pageUrl}</div> </div> <div class="cright"> <div class="clear"></div> {php doAction('feed_index_right_footer')} </div> </div> </div> {template footer}
12ik
trunk/app/feed/html/index.html
HTML
oos
2,742
{php doAction('body_foot')} {php include pubTemplate("footer");}
12ik
trunk/app/feed/html/footer.html
HTML
oos
64
<?php defined('IN_IK') or die('Access Denied.'); return array( 'name' => '动态', 'version' => '1.0', 'desc' => '动态', 'url' => 'http://www.12ik.com', 'email' => '160780470@qq.com', 'author' => '小麦', 'author_url' => 'http://www.12ik.com', 'isoption' => '0', 'isinstall' => '1', 'issql' => '1', 'issystem' => '1', 'isappnav' => '1', );
12ik
trunk/app/feed/about.php
PHP
oos
369
<?php defined('IN_IK') or die('Access Denied.'); /* *包含数据库配置文件 */ require_once IKDATA."/config.inc.php"; $IK_APP['options']['appname'] = '动态'; $skin = 'default';
12ik
trunk/app/feed/config.php
PHP
oos
204
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); //加载风格 include_once 'theme.php'; include_once 'RoomFunction.php'; //页面 switch ($ts) { case "" : //房间显示页面 $roomid = intval($_GET['roomid']); $strRoom = aac('site')->getOneRoom($roomid); //获取于该房间的应用 /*$strBulletins = aac('site')->getBulletinByRoomid($roomid); foreach($strBulletins as $key=>$item) { $str = $item['content']; preg_match_all ( '/\[(url)=([http|https|ftp]+:\/\/[a-zA-Z0-9\.\-\?\=\_\&amp;\/\'\`\%\:\@\^\+\,\.]+)\]([^\[]+)(\[\/url\])/is', $str, $content); foreach($content[2] as $c1) { $str = str_replace ( "[url={$c1}]", '<a href="'.$c1.'">', $str); $str = str_replace ( "[/url]", '</a>', $str); } $strBulletin[] = $item; $strBulletin[$key]['content'] = $str; }*/ //左侧组件 $modsort = aac('site')->getRoomWidgetSort($roomid); $leftTable = explode(',',$modsort['leftmod']); $rightTable = explode(',',$modsort['rightmod']); $strLeftMod = sortMod($leftTable); $strRightMod = sortMod($rightTable); //是否有存档 $countAchives = aac('site')->findCount('site_archive', array('roomid'=>$roomid)); //isRoomEmpty 作标记 不是room的页面全部 false $isRoomEmpty = 1 ; //查询是否被我关注 $userid = $_SESSION['tsuser']['userid']; if($userid>0) { $ismyfollow = aac('site')->find('site_follow', array('userid'=>$userid,'follow_siteid'=>$siteid)); } //查询喜欢该小站的成员 $likeUsers = aac('site')->findAll('site_follow', array('follow_siteid'=>$siteid)); $likesiteNum = 0; foreach($likeUsers as $key=>$item) { $likesiteNum = $key + 1; $arrlikeUser[] = aac('user')->getOneUser($item['userid']); } $title = $strRoom['name']." - ".$strSite['sitename']."的小站"; include template("room"); break; }
12ik
trunk/app/site/action/room.php
PHP
oos
1,915
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); //$userid = $IK_USER['user']['userid']; //$siteid = intval($_GET['siteid']); $roomid = intval($_GET['roomid']); //$strSite = aac('site')->getOneSite($siteid); //页面 switch ($ts) { case "update" : $arrdata = array(); $arrdata['leftmod'] = $_POST['mods']; $arrdata['rightmod'] = $_POST['r_mods']; if(empty($arrdata['leftmod']) && empty($arrdata['leftmod'])) { $arrJson = array('r'=>1, 'html'=>'update layout error'); }else{ aac('site')->update('site_room_widget',array('roomid'=>$roomid),$arrdata); $arrJson = array('r'=>0, 'html'=>'update layout success'); } header("Content-Type: application/json", true); echo json_encode($arrJson); break; }
12ik
trunk/app/site/action/layout.php
PHP
oos
774
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); switch ($ts) { case "" : //未创建小站 //$userid = aac('user')->isLogin(); $title = "我的小站"; include template("index"); break; case "user" : $userid = intval ( $_GET ['userid'] ); //获取用户信息 include template ( 'index' ); break; }
12ik
trunk/app/site/action/index.php
PHP
oos
349
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); //用户是否登录 $userid = aac('user')->isLogin(); $siteid = intval($_GET['siteid']); //定义返回json $arrJson = array(); //初始化 room $arrData = array( 'siteid' => $siteid, 'userid' => $userid, 'name' => '未命名房间', 'addtime' => time(), ); $roomid = $db->insertArr($arrData,dbprefix.'site_room'); $ordertext = aac('site')->getNavOrderBysiteId($siteid); $ordertext = $ordertext['ordertext'].','.$roomid; //初始化导航 $NavOrderId = $db->updateArr(array('ordertext'=>$ordertext),dbprefix.'site_room_navorder','where siteid='.$siteid); if($roomid > 0 && $NavOrderId > 0) { $arrJson['r'] = 0; $arrJson['room'] = SITE_URL.tsUrl('site','room',array('roomid'=>$roomid, 'siteid'=>$siteid)); header("Content-Type: application/json", true); echo json_encode($arrJson); }
12ik
trunk/app/site/action/create_room.php
PHP
oos
907
<?php defined('IN_IK') or die('Access Denied.'); switch($ts){ case "list": //列表 $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $url = SITE_URL.'index.php?app=site&ac=admin&mg=site&ts=list&page='; $lstart = 0;//$page*10-10; //获取全部 //$arrSite = $db->fetch_all_assoc("select * from ".dbprefix."site order by addtime desc limit $lstart,10"); $arrSite = $db->fetch_all_assoc("select * from ".dbprefix."site order by addtime desc "); $siteNum = $db->once_num_rows("select * from ".dbprefix."site"); include template("admin/site_list"); break; case "isaudit": $siteid = $_GET['siteid']; $new['site']->update('site',array( 'siteid'=>$siteid, ),array( 'isaudit' => $_GET['isaudit']==0 ? 1 : 0, )); header("Location: ".SITE_URL."index.php?app=site&ac=admin&mg=site&ts=list"); break; }
12ik
trunk/app/site/action/admin/site.php
PHP
oos
893
<?php defined('IN_IK') or die('Access Denied.'); /* * 配置选项 */ switch($ts){ //基本配置 case "": include template("admin/options"); break; }
12ik
trunk/app/site/action/admin/options.php
PHP
oos
176
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); $notesid = intval($_GET['notesid']); $strNotes = aac('site')->getOneNotes($notesid); $siteid = $strNotes['siteid']; $roomid = $strNotes['roomid']; //导航 $userid = $_SESSION['tsuser']['userid']; //加载风格 include_once 'theme.php'; //页面 switch ($ts) { case "" : //日记显示 $noteid = intval($_GET['noteid']); $strNote = aac('site')->getOneNote($noteid); $strcontent = $strNote['content']; //匹配本地图片 preg_match_all ( '/\[(图片)(\d+)\]/is', $strcontent, $photos ); foreach ($photos [2] as $item) { $strPhoto = aac('site')->getPhotoByseq($noteid,$item); $htmlTpl = '<div class="'.$strPhoto['align'].'"><table><tbody><tr><td> <img alt="'.$strPhoto['photodesc'].'" src="'.$strPhoto['photo_600'].'"> </td></tr><tr><td align="center" class="wr pl">'.$strPhoto['photodesc'].'</td></tr></tbody></table> </div>'; $strcontent = str_replace ( '[图片'.$item.']', $htmlTpl, $strcontent ); } //匹配链接 preg_match_all ( '/\[(url)=([http|https|ftp]+:\/\/[a-zA-Z0-9\.\-\?\=\_\&amp;\/\'\`\%\:\@\^\+\,\.]+)\]([^\[]+)(\[\/url\])/is', $strcontent, $content); foreach($content[2] as $c1) { $strcontent = str_replace ( "[url={$c1}]", '<a href="'.$c1.'" target="_blank">', $strcontent); $strcontent = str_replace ( "[/url]", '</a>', $strcontent); } $strNote['content'] = $strcontent; //更新统计 被浏览数 if($userid != $strNotes['userid']){ $arrData = array('count_view'=> $strNote['count_view']+1); aac('site')->update('site_notes_content',array('contentid'=>$noteid),$arrData); } //评论 $arrComments = aac('site')->findAll('site_note_comment',array('noteid'=>$noteid)); $goon = intval($_GET['goon']); foreach($arrComments as $key => $item) { $arrComment[] = $item; $arrComment[$key]['user'] = aac('user')->getOneUser($item['userid']); } $myComment = aac('site')->find('site_note_comment',array('userid'=>$userid,'noteid'=>$noteid),'','addtime desc'); //判断是否小于60秒之后才能继续发言 $mycommentTime = time() - strtotime(date('Y-m-d H:i:s',$myComment['addtime'])) > 60; if($goon==1 && $userid>0) { $mycommentTime = true; } $title = $strNote['title'].'-'.$strNotes['title']; include template('note'); break; case "settings" : $title = trim($_POST['title']); $roomid = intval($_POST['roomid']);//要转移的房间id $display_number = intval($_POST['display_number']);//显示个数 $strRoom = aac('site')->getOneRoom($strNotes['roomid']); $actionUrl = SITE_URL.tsUrl('site','notes',array('ts'=>'settings','notesid'=>$notesid)); $deleteUrl = SITE_URL.tsUrl('site','notes',array('ts'=>'delete','notesid'=>$notesid)); //判断是否是存档 if($strNotes['isarchive']==1) { $archiveUrl = SITE_URL.tsUrl('site','notes',array('ts'=>'unarchive','notesid'=>$notesid));//恢复url $archiveName = "恢复此应用"; }else{ $archiveUrl = SITE_URL.tsUrl('site','notes',array('ts'=>'archive','notesid'=>$notesid));//存档url $archiveName = "存档此应用"; } $strdis = ''; if($strNotes['display_number']==2) { $strdis = '<label><input value="2" name="display_number" type="radio" checked> 2</label> <label><input value="5" name="display_number" type="radio"> 5</label> <label><input value="10" name="display_number" type="radio"> 10</label>'; }else if ($strNotes['display_number']==5){ $strdis = '<label><input value="2" name="display_number" type="radio"> 2</label> <label><input value="5" name="display_number" type="radio" checked> 5</label> <label><input value="10" name="display_number" type="radio"> 10</label>'; }else if($strNotes['display_number']==10){ $strdis = '<label><input value="2" name="display_number" type="radio"> 2</label> <label><input value="5" name="display_number" type="radio"> 5</label> <label><input value="10" name="display_number" type="radio" checked> 10</label>'; } $options = '<option value="0">选择房间</option>'; foreach($strRooms as $items) { $options = $options.'<option value="'.$items['roomid'].'">'.$items['name'].'</option>'; } $html = ' <form action="'.$actionUrl.'" method="post"> <div style="display:none;"><input type="hidden" name="ck" value="P6J2"/></div> <fieldset> <div class="item"> <label>应用名称:</label> <input type="text" name="title" size="15" maxlength="15" value="'.$strNotes['title'].'"> </div> <div class="item item-display-num"> <label>显示个数:</label> <span class="item-r">'.$strdis.'</span> </div> <div class="item"> <label>移动到:</label> <select name="roomid">'.$options.'</select> </div> <div class="item-submit"> <span class="bn-flat-hot"><input type="submit" value="保存"></span> <a href="#" class="a_cancel_setting_panel">取消</a> <span class="setting-panel-ops"> <a href="'.$archiveUrl.'" class="a_archive_mod" screen_name="日记" title="'.$strNotes['title'].'" room_name="'.$strRoom['name'].'">'.$archiveName.'</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="'.$deleteUrl.'" class="a_delete_mod" title="真的要删除此应用?">删除</a> </span> </div> </fieldset> </form> '; //开始分发数据 $arrdata = array(); if(!empty($title)) $arrdata['title'] = $title; if(!empty($title)) $arrdata['display_number'] = $display_number; if(!empty($roomid) && $roomid!=0) $arrdata['roomid'] = $roomid; //判断是更新还是 设置请求 if(!empty($arrdata)) { //更新 $new['site']->update('site_notes',array('notesid'=>$notesid),array( 'title'=>$arrdata['title'],'display_number'=>$arrdata['display_number'] )); if(!empty($arrdata['roomid']) && $arrdata['roomid']!=$strNotes['roomid']) { $arrstatus = aac('site')->moveWidget($strNotes['roomid'], $roomid, 'notes-'.$notesid); if($arrstatus['status']==0) { //成功了 更新组件 房间id $db->query("update ".dbprefix."site_notes set roomid='$roomid' where notesid='$notesid'"); $arrJson = array('r'=>0, 'html'=>''); }else if($arrstatus['status']==1) { $arrJson = array('r'=>1, 'error'=>$arrstatus['roomname'].'房间应用个数已达上限,先移除几个吧'); } header("Content-Type: application/json", true); echo json_encode($arrJson); exit(); }else{ //取数据 $tables = aac('site')->findAll('site_notes_content',array('notesid'=>$notesid),'addtime desc', '','0,'.$display_number.''); $html = ''; //如果有数据 if($tables) { foreach($tables as $item) { $html .= ' <div class="item-entry"> <div class="title"> <a href="'.SITE_URL.tsUrl('site','notes',array('notesid'=>$item['notesid'],'noteid'=>$item['contentid'])).'" title="'.$item['title'].'">'.$item['title'].'</a> </div> <div class="datetime">'.date('Y-m-d H:i:s',$item['addtime']).'</div> <div id="note_'.$item['contentid'].'_short" class="summary">'.getsubstrutf8(t($item['content']),0,120).'<a href="'.SITE_URL.tsUrl('site','notes',array('notesid'=>$item['notesid'],'noteid'=>$item['contentid'])).'#note_'.$item['contentid'].'_footer">('.$item['count_comment'].'回应)</a> </div> </div> '; } }else{ $html ='<div class="createnew">记录你的最新动向 <a href="'.SITE_URL.tsUrl('site','notes', array('ts'=>'create','notesid'=>$notesid)).'"> &gt; 提笔写日记</a></div>'; } $arrJson = array('r'=>0, 'html'=>$html); header("Content-Type: application/json", true); echo json_encode($arrJson); exit(); } }else{ $arrJson = array('r'=>0, 'html'=>$html); header("Content-Type: application/json", true); echo json_encode($arrJson); } break; case "archive" : //存档应用 aac('site')->isAllow($strNotes['userid'],$userid,'archive'); //更新 并存档 aac('site')->update('site_notes',array('notesid'=>$notesid),array('isarchive'=>1)); $tables = aac('site')->find('site_notes', array('notesid'=>$notesid)); $isarchive = $tables['isarchive']; $roomid = $tables['roomid']; if($isarchive==1) { $archiveid = aac('site')->create('site_archive', array( 'roomid'=>$roomid, 'widgetid'=>$notesid, 'widgetname'=>'notes', 'addtime'=>time() )); } if(!empty($archiveid)) { $arrJson = array('r'=>0, 'html'=>'success'); }else{ $arrJson = array('r'=>1, 'error'=>'存档失败,请重试!'); } header("Content-Type: application/json", true); echo json_encode($arrJson); break; case "unarchive" : //存档应用 aac('site')->isAllow($strNotes['userid'],$userid,'unarchive'); //更新 并存档 aac('site')->update('site_notes',array('notesid'=>$notesid),array('isarchive'=>0)); $tables = aac('site')->find('site_notes', array('notesid'=>$notesid)); $isarchive = $tables['isarchive']; $roomid = $tables['roomid']; if($isarchive==0) { //删除存档 $archiveid = aac('site')->delete('site_archive', array('widgetid'=>$notesid,'widgetname'=>'notes','roomid'=>$roomid)); } if(!empty($archiveid)) { $arrJson = array('r'=>0, 'html'=>'success'); }else{ $arrJson = array('r'=>1, 'error'=>'恢复失败,请重试!'); } header("Content-Type: application/json", true); echo json_encode($arrJson); break; case "delete" : //删除组件 //判断权限 aac('site')->isAllow($strNotes['userid'],$userid,'delete'); //判断是否有数据 $isDel = aac('site')->findCount('site_notes_content',array('notesid'=>$notesid)); if($isDel > 0) { $arrJson = array('r'=>1, 'error'=>'请先清空内容,再删除。'); }else{ //删除布局 $arrLayout = aac('site')->delWidget($strNotes['roomid'], 'notes-'.$notesid); aac('site')->update('site_room_widget',array('roomid'=>$strNotes['roomid']),$arrLayout); //删除组件 $new['site']->delete('site_notes',array('notesid'=>$notesid)); //删除存档表里数据 $new['site']->delete('site_archive',array('widgetname'=>'notes','widgetid'=>$notesid)); //更新site_room表 组件数 $db->query("update ".dbprefix."site_room set count_widget = count_widget-1 where roomid='$strNotes[roomid]'"); $arrJson = array('r'=>0, 'html'=>'delete success'); } header("Content-Type: application/json", true); echo json_encode($arrJson); break; case "create" : //判断权限 aac('site')->isAllow($strNotes['userid'],$userid,'create'); //新建日记 $note_submit = trim($_POST['note_submit']); //提交按钮 $cancel_note = trim($_POST['cancel_note']); //取消发布按钮 $isreply = intval($_POST['isreply']); //是否允许评论 $note_title = trim($_POST['note_title']); $note_content = trim($_POST['note_content']); $note_id = trim($_POST['note_id']); //预先执行添加一条记录 $strLastnote = aac('site')->find('site_notes_content',array('userid'=>$userid, 'notesid'=>0)); if($strLastnote['contentid']>0) { $noteid = $strLastnote['contentid']; }else{ $noteid = aac('site')->create('site_notes_content', array('userid'=>$userid, 'notesid'=>0,'title'=>'0','content'=>'0','addtime'=>time()) ); } //浏览该noteid下的照片 $arrPhotos = aac('site')->getPhotosByNoteid($userid, $noteid); //提交按钮 if($note_submit) { if($note_title=='' || $note_content=='') tsNotice("标题和内容都不能为空!"); if(mb_strlen($title,'utf8')>64) tsNotice('标题很长很长很长很长...^_^'); if(mb_strlen($content,'utf8')>50000) tsNotice('发这么多内容干啥^_^'); //执行添加 aac('site')->update('site_notes_content', array('contentid'=>$noteid), array('notesid'=>$notesid, 'title'=>$note_title,'content'=>htmlspecialchars($note_content),'addtime'=>time()) ); //执行更新图片***********************************************// foreach($arrPhotos as $key=>$item) { $photo_seqid = intval($_POST['p'.$item['seqid'].'_seqid']); $photodesc = $_POST['p'.$item['seqid'].'_title']; $photo_align = $_POST['p'.$item['seqid'].'_align']; if($photo_seqid > 0) { //存在表单 开始执行更新 $arrData = array( 'photodesc' => $photodesc, 'align' => $photo_align, ); aac('site')->update('site_note_photo',array('noteid'=>$note_id,'seqid'=>$photo_seqid), $arrData); } } //////////////////////////////////////////////////////////// header("Location: ".SITE_URL.tsUrl('site','notes',array('notesid'=>$notesid,'noteid'=>$note_id))); } $title = '新加日记'; include template('notes_create'); break; case "edit" : //判断权限 aac('site')->isAllow($strNotes['userid'],$userid,'create'); //日记编辑 显示 $noteid = intval($_GET['noteid']); $arrNote = aac('site')->find('site_notes_content',array('contentid'=>$noteid)); //浏览该noteid下的照片 $arrPhotos = aac('site')->getPhotosByNoteid($userid, $noteid); //接收提交数据 $note_submit = trim($_POST['note_submit']); //提交按钮 $cancel_note = trim($_POST['cancel_note']); //取消发布按钮 $isreply = intval($_POST['isreply']); //是否允许评论 $note_title = trim($_POST['note_title']); $note_content = trim($_POST['note_content']); $note_id = trim($_POST['note_id']); //提交按钮 if($note_submit) { if($note_title=='' || $note_content=='') tsNotice("标题和内容都不能为空!"); if(mb_strlen($title,'utf8')>64) tsNotice('标题很长很长很长很长...^_^'); if(mb_strlen($content,'utf8')>50000) tsNotice('发这么多内容干啥^_^'); //执行更新 aac('site')->update('site_notes_content', array('contentid'=>$noteid), array('notesid'=>$notesid, 'title'=>$note_title,'content'=>htmlspecialchars($note_content),'addtime'=>time()) ); //执行更新图片***********************************************// foreach($arrPhotos as $key=>$item) { $photo_seqid = intval($_POST['p'.$item['seqid'].'_seqid']); $photodesc = $_POST['p'.$item['seqid'].'_title']; $photo_align = $_POST['p'.$item['seqid'].'_align']; if($photo_seqid > 0) { //存在表单 开始执行更新 $arrData = array( 'photodesc' => $photodesc, 'align' => $photo_align, ); aac('site')->update('site_note_photo',array('noteid'=>$note_id,'seqid'=>$photo_seqid), $arrData); } } //////////////////////////////////////////////////////////// header("Location: ".SITE_URL.tsUrl('site','notes',array('notesid'=>$notesid,'noteid'=>$note_id))); } $title = '编辑日记'; include template('notes_edit'); break; case "delnote" : //判断权限 aac('site')->isAllow($strNotes['userid'],$userid,'delete'); //日记del $noteid = intval($_GET['noteid']); //删除评论 aac('site')->delete('site_note_comment',array('noteid'=>$noteid)); //删除照片 aac('site')->delete('site_note_photo',array('noteid'=>$noteid)); //删除帖子 aac('site')->delete('site_notes_content',array('contentid'=>$noteid,'notesid'=>$notesid)); header("Location: ".SITE_URL.tsUrl('site','notes',array('ts'=>'list','notesid'=>$notesid))); break; case "list" : //日记列表 $arrNote = aac('site')->findAll('site_notes_content',array('notesid'=>$notesid),'addtime desc'); include template('notes_list'); break; case "add_comment" : //判断权限 $userid = aac('user')->isLogin();//登录发言 $noteid = intval($_GET['noteid']); $content = trim($_POST['content']); if($content=='') { tsNotice('没有任何内容是不允许你通过滴^_^'); } $commentid =aac('site')->create('site_note_comment', array('referid'=>'0','noteid'=>$noteid, 'userid'=>$userid,'content'=>htmlspecialchars($content),'addtime'=>time()) ); $strCount = aac('site')->getOneNote($noteid); if($commentid>0){ //执行update回复数 aac('site')->update('site_notes_content', array('notesid'=>$notesid,'contentid'=>$noteid), array('count_comment'=>$strCount['count_comment']+1) ); } header("Location: ".SITE_URL.tsUrl('site','notes',array('notesid'=>$notesid,'noteid'=>$noteid))); break; case "del_comment" : $noteid = intval($_GET['noteid']); $commentid = intval($_GET['commentid']); $strComment = aac('site')->find('site_note_comment',array('commentid'=>$commentid)); //判断权限 if($strNotes['userid']!=$userid && $strComment['userid']!=$userid) { tsNotice('你没有执行该操作(del_comment)的权限!'); }else if(empty($userid)){ tsNotice('你没有执行该操作(del_comment)的权限!','请登录后重试',SITE_URL.tsUrl('user','login')); } aac('site')->delete('site_note_comment',array('commentid'=>$commentid,'noteid'=>$noteid)); $strCount = aac('site')->getOneNote($noteid); //执行update回复数 aac('site')->update('site_notes_content', array('notesid'=>$notesid,'contentid'=>$noteid), array('count_comment'=>$strCount['count_comment']-1) ); header("Location: ".SITE_URL.tsUrl('site','notes',array('notesid'=>$notesid,'noteid'=>$noteid))); break; case "add_photo" : $note_id = $_POST['note_id']; $userid = intval($_POST['userid']); //$ck = $_POST['ck']; $photonum = aac('site')->findCount('site_note_photo',array('noteid'=>$note_id)); $arrUpload = tsUpload($_FILES['image_file'],$photonum+1,'site/note/'.$note_id,array('jpg','gif','png')); if($arrUpload) { //插入数据库 $arrData = array( 'seqid' => $photonum+1, 'userid' => $userid, 'noteid' => $note_id, 'photoname' => $arrUpload['name'], 'phototype' => $arrUpload['type'], 'photosize' => $arrUpload['size'], 'path' => 'note/'.$note_id.'/'.$arrUpload['path'], 'photourl' => 'note/'.$note_id.'/'.$arrUpload['url'], 'addtime' => time(), ); aac('site')->create('site_note_photo', $arrData); //清除缓存图片 //ClearAppCache($app.'/note/'.$note_id.'/'.$arrUpload['path']); //浏览该noteid下的照片 $arrPhoto = aac('site')->getPhotoByseq($note_id,$photonum+1); $arrparam = array('file_name'=>$arrPhoto['photoname'], 'file_size'=>$arrPhoto['photosize'], 'id'=>$note_id,'seq'=>$photonum+1,'thumb'=>$arrPhoto['photo_140']); $arrJson = array('r'=>0, 'photo'=>$arrparam); echo json_encode($arrJson); }else{ $arrJson = array('r'=>1, 'err'=>"上传失败,请重试!"); echo json_encode($arrJson); } //header("Content-Type: application/json", true); //echo json_encode($arrJson); break; }
12ik
trunk/app/site/action/notes.php
PHP
oos
19,303
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); $siteid = intval($_GET['id']); //加载风格 include_once 'theme.php'; //页面 switch ($ts) { case "" : //小站管理员 $adminUser = aac('user')->getOneUser($strSite['userid']); //查询喜欢该小站的成员 $likeUsers = aac('site')->findAll('site_follow', array('follow_siteid'=>$siteid)); $likesiteNum = 0; foreach($likeUsers as $key=>$item) { $likesiteNum = $key + 1; $arrlikeUser[] = aac('user')->getOneUser($item['userid']); } $title = "喜欢".$strSite['sitename']."的成员(".$likesiteNum.")"; include template("likers"); break; }
12ik
trunk/app/site/action/likers.php
PHP
oos
649
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); //排序 function sortMod($mod) { $strMods = array(); foreach($mod as $key => $item) { $item = explode('-',$item); // $item[0] 表名 $item[1] 数据id //公告栏 if($item[0]=='bulletin') { $tables = aac('site')->find('site_bulletin', array('bulletinid'=>$item[1], 'isarchive'=>'0')); if(!empty($tables)) { $str = $tables['content']; preg_match_all ( '/\[(url)=([http|https|ftp]+:\/\/[a-zA-Z0-9\.\-\?\=\_\&amp;\/\'\`\%\:\@\^\+\,\.]+)\]([^\[]+)(\[\/url\])/is', $str, $content); foreach($content[2] as $c1) { $str = str_replace ( "[url={$c1}]", '<a href="'.$c1.'" target="_blank">', $str); $str = str_replace ( "[/url]", '</a>', $str); } $strMods[$key]['table'] = 'bulletin'; $strMods[$key]['itemid'] = $item[1]; $strMods[$key]['title'] = $tables['title']; $strMods[$key]['settingurl'] = '<a href="#" rel="'.SITE_URL.tsUrl('site','bulletin',array('ts'=>'settings','bulletinid'=>$item[1])).'" class="a_lnk_mod_setting">设置</a>'; $strMods[$key]['action'] = '<a href="'.SITE_URL.tsUrl('site','bulletin',array('ts'=>'update','bulletinid'=>$item[1])).'">修改</a>'; $strMods[$key]['content'] = $str; } } //日记 if($item[0]=='notes') { $tables = aac('site')->find('site_notes', array('notesid'=>$item[1],'isarchive'=>'0')); if(!empty($tables)) { $display_number = $tables['display_number']; $strMods[$key]['table'] = 'notes'; $strMods[$key]['itemid'] = $item[1]; $strMods[$key]['title'] = $tables['title']; $strMods[$key]['settingurl'] = '<a href="#" rel="'.SITE_URL.tsUrl('site','notes',array('ts'=>'settings','notesid'=>$item[1])).'" class="a_lnk_mod_setting">设置</a>'; $strMods[$key]['list'] = '<a href="'.SITE_URL.tsUrl('site','notes',array('ts'=>'list','notesid'=>$item[1])).'">全部</a>'; $strMods[$key]['action'] = '<a href="'.SITE_URL.tsUrl('site','notes',array('ts'=>'create','notesid'=>$item[1])).'">添加新日记</a>'; $strMods[$key]['content'] = aac('site')->findAll('site_notes_content', array('notesid'=>$item[1]),'addtime desc', '','0,'.$display_number.''); //图片问题 } } //论坛 if($item[0]=='forum') { $tables = aac('site')->find('site_forum', array('forumid'=>$item[1], 'isarchive'=>'0')); if(!empty($tables)) { $display_number = $tables['display_number']; $strMods[$key]['table'] = $item[0]; $strMods[$key]['itemid'] = $item[1]; $strMods[$key]['title'] = $tables['title']; $strMods[$key]['settingurl'] = '<a href="#" rel="'.SITE_URL.tsUrl('site','forum',array('ts'=>'settings', 'forumid'=>$item[1])).'" class="a_lnk_mod_setting">设置</a>'; $strMods[$key]['list'] = '<a href="'.SITE_URL.tsUrl('site','forum', array('ts'=>'list','forumid'=>$item[1])).'">全部</a>'; $strMods[$key]['action'] = '<a href="'.SITE_URL.tsUrl('site','forum', array('ts'=>'create','forumid'=>$item[1])).'">发言</a>'; $strMods[$key]['content'] = aac('site')->findAll('site_forum_discuss', array('forumid'=>$item[1]),'istop desc,addtime desc', '','0,'.$display_number.''); } } } return $strMods; }
12ik
trunk/app/site/action/RoomFunction.php
PHP
oos
3,407
<?php defined ( 'IN_IK' ) or die ( 'Access Denied.' ); //用户是否登录 $userid = aac('user')->isLogin(); $siteid = intval($_GET['siteid']); $roomid = intval($_GET['roomid']); $roomname = htmlspecialchars(trim($_POST['name'])); //定义返回json $arrJson = array(); //开始创建room $arrData = array( 'name' => $roomname , 'addtime' => time(), ); $isupdate = $db->updateArr($arrData,dbprefix.'site_room','where siteid='.$siteid.' and roomid='.$roomid); if($isupdate) { $arrJson['r'] = 0; header("Content-Type: application/json", true); echo json_encode($arrJson); }
12ik
trunk/app/site/action/roomRename.php
PHP
oos
626